Re: Re: [RFCv4 06/11] misc: Introduce Nokia CMT driver

From: Sebastian Reichel
Date: Tue Dec 17 2013 - 18:25:44 EST


On Tue, Dec 17, 2013 at 07:58:56PM +0200, Ivajlo Dimitrov wrote:
> >On Mon, Dec 16, 2013 at 02:31:53PM +0100, Linus Walleij wrote:
> >>I am very reluctant in letting device trees specify exports of GPIOs
> >>to userspace, not so much because it's Linux-specific but for
> >>the fact that people are doing things in userspace that should not
> >>be done in userspace.
> >>
> >>Last time it was proposed I asked to the specific usecase,
> >>exactly why userspace needed this handle on a physical
> >>GPIO line, and why it can't use another userspace interface
> >>(example: leds, keys etc.)
> >There are a couple of lines ("cmt_apeslpx", "cmt_rst_rq", "cmt_en",
> >"cmt_rst", "cmt_bsi"), which are handled by ofono to do the correct
> >power sequence for the modem. The relevant ofono code is here:
> >
> >https://git.kernel.org/cgit/network/ofono/ofono.git/tree/plugins/nokia-gpio.c
> >
> >In MeeGo etc. they have a little board specific init script, which
> >exports the gpio lines and setups some symlinks. IMHO at least the
> >board specific stuff should be handled by the kernel, thus I added
> >this code to the driver. I guess you prefer to move the power
> >sequencing completly to the kernel?
>
> Don't forget there is not only ofono, but rtcom-call-ui and all the
> telephony stack in Maemo 5 :). However, power sequencing and control
> is specific not only to the modem model, but to the firmware version
> the modem is running as well (afaik). IMO you can't simply move the
> modem power/reset/sleep control to the kernel and hope for the best,
> I am not sure there is enough documentation (if any) for this to be
> done reliably, esp on n900 with its BB5 modem. The point is that
> those gpios are used not only for the initial power-up, but for
> control of the modem state and reset (if needed) during normal
> usage. The APE reset line is an example of stuff that can't be moved
> to the kernel without providing some interface/feedback to/from the
> userspace IMO - what if she is dialing 112 at the moment the modem
> decides it is too hot and wants a device reset (or whatever reason
> there could be for a modem to request a device reset)? The same goes
> for the APE sleep request line (cmt_apeslpx) - based on what should
> the kernel decide whether to put the modem in sleep?
>
> Sure, exporting gpios to userspace might not be the best way to
> achieve the required functionality, but every way could be argued if
> it is the best. And for sure labeling a modem "LED" won't make it
> such.

Yes, but as far as I know the kernel design rules are not bended for
nonfree userspace components. Using the nonfree Maemo stuff should
be supported by disabling the CMT driver and exporting the pins from
userspace using some board specific init script (=> this is how its
done until now).

I had a look at both ofono's and freesmartphone.org's implementation
for the GPIO handling and both implementations are very similar. I
think it should be possible to move the state machine described in
[0] into the kernel and provide a simple sysfs/uevent interface.

I was thinking of something like /sys/devices/platform/nokia-cmt/state,
which accepts "enable", "disable" and "reset" as input and outputs the
current state.

[0] https://git.kernel.org/cgit/network/ofono/ofono.git/tree/plugins/nokia-gpio.c

-- Sebastian

Attachment: signature.asc
Description: Digital signature