How to write driver that needs to call another driver?

From: Stanislav Brabec
Date: Tue Jan 26 2010 - 16:09:47 EST


My Zaurus SL-C3200 PDA needs a driver that needs to call another driver
from another part of the device tree:

MAX1111 (4 channel A/D) is connected to several other pieces of hardware
(audio player remote keyboard, battery voltage, battery temperature,
external power voltage).

Battery power and charging management needs to read values from MAX1111
during. Also Remote Keyboard input device needs to read MAX1111.

But both drivers also need dedicated GPIO that are allocated on Scoop
chip (different part of the platform device tree).

What is the best way to implement it?

Now it is implemented by a hardcoded static reference. This does not
work well and breaks on suspend. MAX1111 goes to sleep first and attempt
to set-up offline charging fails (see below).

I need to make sure, that MAX1111 is going to suspend after the
battery management and after the audio remote driver (not yet in
vanilla) and resumes before them.

What is the best way to implement it?


Well, in fact, the problem is even worse: Spitz has a dumb charging
management. CPU has to wake-up each few minutes, check the battery,
adjust charging parameters and continue in sleeping.

That is why I either need to disable sleeping of SPI and MAX1111 or
temporarily wake up SPI and MAX111 without going to resume completely.

Is something like this possible?

It was working in past (linux-2.6.26) - MAX1111+SPI driver was hardcoded
into power management and when SPI was probably never suspended. Now it
obviously cannot work.

Thanks.

PM: suspend of devices complete after 549.298 msecs
PM: late suspend of devices complete after 0.359 msecs
max1111 spi2.2: spi_sync failed with -108
max1111 spi2.2: spi_sync failed with -108
max1111 spi2.2: spi_sync failed with -108
max1111 spi2.2: spi_sync failed with -108
max1111 spi2.2: spi_sync failed with -108
sharpsl-pm sharpsl-pm: Error: AC check failed: voltage -108.
sharpsl-pm sharpsl-pm: Offline Charger: Error occurred.
sharpsl-pm sharpsl-pm: Charging Error!
PM: early resume of devices complete after 0.255 msecs


________________________________________________________________________
Stanislav Brabec
http://www.penguin.cz/~utx

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/