linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Analog Digital Converter - ADS1256 extreme newbie questions
@ 2010-09-10  5:13 Flávio Alberto Lopes Soares
  0 siblings, 0 replies; 5+ messages in thread
From: Flávio Alberto Lopes Soares @ 2010-09-10  5:13 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hello all,
I'm working 9 years as a Linux C/C++ programmer but I spent 99,9% of this
time working in user space programming, now I need to write a driver to use
the ADS1256 Analog-Digital converter (
http://focus.ti.com/docs/prod/folders/print/ads1256.html ) in an ARM board
using S3C2440 processor, my lecture start point
was Documentation/spi/spi-sumary from 2.6.32.2 kernel tree version and
drivers/misc/eeprom/at25.c code (this is an eeprom driver but I want look
the SPI general view), reading the text and the code I found some conceptual
doubts, my initial idea was create a character device driver and attach the
device read operation with a ADS1256 start lecture and pass the ADC channel
data to this device, this concept is correct ? There's some standard
interface to do this if my idea is wrong ?

Looking in at25.c in at25_probe(struct spi_device *spi) function this
"struct spi_device *spi" parameter represents the S3C2440 SPI controller and
came from SPI core subsystem ? If yes how the SPI controller knows that this
is an eeprom device in the snippet bellow ?
...
const struct spi_eeprom *chip;
...
/* Chip description */
chip = spi->dev.platform_data;

who provides this platform_data structure and who knows it must be a struct
spi_eeprom object ?

Thanks for all help

Flávio Alberto Lopes Soares
------------------------------------------------------------------------------
Automate Storage Tiering Simply
Optimize IT performance and efficiency through flexible, powerful, 
automated storage tiering capabilities. View this brief to learn how
you can reduce costs and improve performance. 
http://p.sf.net/sfu/dell-sfdev2dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Analog Digital Converter - ADS1256 extreme newbie questions
@ 2010-09-10 13:11 Flávio Alberto Lopes Soares
       [not found] ` <AANLkTi=iQVwpd-PymaWSKapfntmf4aRrt51Jutsz=D_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Flávio Alberto Lopes Soares @ 2010-09-10 13:11 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hello all,
I'm working 9 years as a Linux C/C++ programmer but I spent 99,9% of this
time working in user space programming, now I need to write a driver to use
the ADS1256 Analog-Digital converter (
http://focus.ti.com/docs/prod/folders/print/ads1256.html ) in an ARM board
using S3C2440 processor, my lecture start point
was Documentation/spi/spi-sumary from 2.6.32.2 kernel tree version and
drivers/misc/eeprom/at25.c code (this is an eeprom driver but I want look
the SPI general view), reading the text and the code I found some conceptual
doubts, my initial idea was create a character device driver and attach the
device read operation with a ADS1256 start lecture and pass the ADC channel
data to this device, this concept is correct ? There's some standard
interface to do this if my idea is wrong ?

Looking in at25.c in at25_probe(struct spi_device *spi) function this
"struct spi_device *spi" parameter represents the S3C2440 SPI controller and
came from SPI core subsystem ? If yes how the SPI controller knows that this
is an eeprom device in the snippet bellow ?
...
const struct spi_eeprom *chip;
...
/* Chip description */
chip = spi->dev.platform_data;

who provides this platform_data structure and who knows it must be a struct
spi_eeprom object ?

Thanks for all help

Flávio Alberto Lopes Soares
------------------------------------------------------------------------------
Automate Storage Tiering Simply
Optimize IT performance and efficiency through flexible, powerful, 
automated storage tiering capabilities. View this brief to learn how
you can reduce costs and improve performance. 
http://p.sf.net/sfu/dell-sfdev2dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Analog Digital Converter - ADS1256 extreme newbie questions
       [not found] ` <AANLkTi=iQVwpd-PymaWSKapfntmf4aRrt51Jutsz=D_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2010-09-10 17:18   ` Grant Likely
       [not found]     ` <20100910171858.GA11284-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Grant Likely @ 2010-09-10 17:18 UTC (permalink / raw)
  To: Flávio Alberto Lopes Soares
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Fri, Sep 10, 2010 at 10:11:35AM -0300, Flávio Alberto Lopes Soares wrote:
> Hello all,
> I'm working 9 years as a Linux C/C++ programmer but I spent 99,9% of this
> time working in user space programming, now I need to write a driver to use
> the ADS1256 Analog-Digital converter (
> http://focus.ti.com/docs/prod/folders/print/ads1256.html ) in an ARM board
> using S3C2440 processor, my lecture start point
> was Documentation/spi/spi-sumary from 2.6.32.2 kernel tree version and
> drivers/misc/eeprom/at25.c code (this is an eeprom driver but I want look
> the SPI general view), reading the text and the code I found some conceptual
> doubts, my initial idea was create a character device driver and attach the
> device read operation with a ADS1256 start lecture and pass the ADC channel
> data to this device, this concept is correct ? There's some standard
> interface to do this if my idea is wrong ?
> 
> Looking in at25.c in at25_probe(struct spi_device *spi) function this
> "struct spi_device *spi" parameter represents the S3C2440 SPI controller and
> came from SPI core subsystem ? If yes how the SPI controller knows that this
> is an eeprom device in the snippet bellow ?
> ...
> const struct spi_eeprom *chip;
> ...
> /* Chip description */
> chip = spi->dev.platform_data;
> 
> who provides this platform_data structure and who knows it must be a struct
> spi_eeprom object ?

Hi Flávio.

The platform_data structure is provided by the code that registers the
spi_device; usually this is some form of machine specific platform
code in an arch/*/ subdirectory.  The driver knows that platform_data
points to the drivers structure because the code that registered the
device must be responsible to provide the right kind of platform_data
pointer for the driver that will be bound to it.

For an example, look at arch/arm/mach-omap2/board-3430sdp.c which has
an spi_board_info structure which passes both the requested driver
(.modalias = "ads7846") and the data structure required by the ads7846
driver (.platform_data = "&tsc2046_config").

The matching driver is drivers/input/touchscreen/ads7846.c

You'll notice that board-3430sdp.c and ads7846.c both use the
ads7846_platform_data structure.

g.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Analog Digital Converter - ADS1256 extreme newbie questions
       [not found]     ` <20100910171858.GA11284-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
@ 2010-09-12 14:39       ` Flávio Alberto Lopes Soares
       [not found]         ` <AANLkTikXq6Wm0kA_cHiAyZc+5kOJQBvP_2gOSbnihv5i-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Flávio Alberto Lopes Soares @ 2010-09-12 14:39 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hi Grant,
thank you for your help.

I misunderstood the "struct spi_device *spi" that functions in protocol
drivers receive as parameters, for example in the probe function, I thought
that spi_device struct represent the spi master controller but as I saw
in Documentation/DocBook/device-drivers/ch09.html it represents itself and
not the SPI controller.

But, comparing drivers/staging/iio/accel/kxsd9.c
and drivers/misc/eeprom/at25.c why kxsd9 driver doesn't uses the
platform_data struct ? There's some functional difference in these 2 drivers
in the way that they access the SPI subsystem ?
I'm thinking of use the kxsd9.c as a "master" to write my driver because the
apparent simplicity way of access the SPI subsystem, I like it.

Thanks for all help
Flavio Alberto Lopes Soares

2010/9/10 Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>

> On Fri, Sep 10, 2010 at 10:11:35AM -0300, Flávio Alberto Lopes Soares
> wrote:
> > Hello all,
> > I'm working 9 years as a Linux C/C++ programmer but I spent 99,9% of this
> > time working in user space programming, now I need to write a driver to
> use
> > the ADS1256 Analog-Digital converter (
> > http://focus.ti.com/docs/prod/folders/print/ads1256.html ) in an ARM
> board
> > using S3C2440 processor, my lecture start point
> > was Documentation/spi/spi-sumary from 2.6.32.2 kernel tree version and
> > drivers/misc/eeprom/at25.c code (this is an eeprom driver but I want look
> > the SPI general view), reading the text and the code I found some
> conceptual
> > doubts, my initial idea was create a character device driver and attach
> the
> > device read operation with a ADS1256 start lecture and pass the ADC
> channel
> > data to this device, this concept is correct ? There's some standard
> > interface to do this if my idea is wrong ?
> >
> > Looking in at25.c in at25_probe(struct spi_device *spi) function this
> > "struct spi_device *spi" parameter represents the S3C2440 SPI controller
> and
> > came from SPI core subsystem ? If yes how the SPI controller knows that
> this
> > is an eeprom device in the snippet bellow ?
> > ...
> > const struct spi_eeprom *chip;
> > ...
> > /* Chip description */
> > chip = spi->dev.platform_data;
> >
> > who provides this platform_data structure and who knows it must be a
> struct
> > spi_eeprom object ?
>
> Hi Flávio.
>
> The platform_data structure is provided by the code that registers the
> spi_device; usually this is some form of machine specific platform
> code in an arch/*/ subdirectory.  The driver knows that platform_data
> points to the drivers structure because the code that registered the
> device must be responsible to provide the right kind of platform_data
> pointer for the driver that will be bound to it.
>
> For an example, look at arch/arm/mach-omap2/board-3430sdp.c which has
> an spi_board_info structure which passes both the requested driver
> (.modalias = "ads7846") and the data structure required by the ads7846
> driver (.platform_data = "&tsc2046_config").
>
> The matching driver is drivers/input/touchscreen/ads7846.c
>
> You'll notice that board-3430sdp.c and ads7846.c both use the
> ads7846_platform_data structure.
>
> g.
>
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Analog Digital Converter - ADS1256 extreme newbie questions
       [not found]         ` <AANLkTikXq6Wm0kA_cHiAyZc+5kOJQBvP_2gOSbnihv5i-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2010-09-12 20:30           ` Grant Likely
  0 siblings, 0 replies; 5+ messages in thread
From: Grant Likely @ 2010-09-12 20:30 UTC (permalink / raw)
  To: Flávio Alberto Lopes Soares,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f



"Flávio Alberto Lopes Soares" <flavioalsoares@gmail.com> wrote:
[…]
>But, comparing drivers/staging/iio/accel/kxsd9.c
>and drivers/misc/eeprom/at25.c why kxsd9 driver doesn't uses the
>platform_data struct ? There's some functional difference in these 2 drivers
>in the way that they access the SPI subsystem ?

platform_data is a method for passing additional data to a driver that doesn't fit in the spi_device structure.  Drivers are not required to use platform_data.

g.

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-09-12 20:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-10  5:13 Analog Digital Converter - ADS1256 extreme newbie questions Flávio Alberto Lopes Soares
  -- strict thread matches above, loose matches on Subject: below --
2010-09-10 13:11 Flávio Alberto Lopes Soares
     [not found] ` <AANLkTi=iQVwpd-PymaWSKapfntmf4aRrt51Jutsz=D_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-09-10 17:18   ` Grant Likely
     [not found]     ` <20100910171858.GA11284-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-09-12 14:39       ` Flávio Alberto Lopes Soares
     [not found]         ` <AANLkTikXq6Wm0kA_cHiAyZc+5kOJQBvP_2gOSbnihv5i-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-09-12 20:30           ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).