OMAP SSI driver / N900 modem support
Subsystems (3)
v4 cover OMAP SSI driver / N900 modem support
Hi,
This is the fourth round of the OMAP SSI driver patches.
I added some more patches on top of the actual OMAP SSI driver, so that one can get the overall picture of the planned architecture. This patchset contains everything, that is needed to get the N900's modem running (without audio support, which requires another hsi client driver).
After applying the patches one can use ofono with the N900's modem. This is what I did to test the modem:
# get ofono and mdbus2 to send some dbus commands apt-get install ofono mdbus2 # ofono assumes, that gpios are available in /dev/cmt. Previously # a init script exported the gpios and symlinked them to this # directory. I added support for the gpio export directly into # nokia-cmt and I plan to write a patch for ofono to check for # the cmt gpios directly in /sys. For now this hack can be used # to test the modem. ln -sf /sys/devices/nokia-cmt.5 /dev/cmt # start ofono in debug mode export OFONO_ISI_DEBUG export OFONO_AT_DEBUG=1 ofono --nodetach --debug # enable the modem mdbus2 -s org.ofono /n900_0 org.ofono.Modem.SetProperty Powered true # enable modem's RF parts mdbus2 -s org.ofono /n900_0 org.ofono.Modem.SetProperty Online true # scan for available networks mdbus2 -s org.ofono /n900_0 org.ofono.NetworkRegistration.Scan
Changes since RFCv3 [0]:
* Added new patches for nokia-cmt driver
* Added new patches for ssi protocol driver
* Removal of ti,hwmods description from DT Documentation
* Removed the hwmod patch, since it has already been applied
* Misc. bug fixes
TODO (short-term):
* Find a DT maintainer, who has time to review the updated DT bindings
* Push nokia-cmt driver through gregkh's linux-misc queue
* Push hsi/ssi drivers through my new linux-hsi queue [1]
* Push DTS patches through benoits queue once the other patches are queued
TODO (long-term):
* Central Message Queue
I did not yet implement a central message queue in the HSI framework. I will do this after Nokia N900 modem is working in the mainline kernel.
* Get clock data from DT
This depends on a patchset, which is not yet part of any kernel tree. Apart from that I don't know which clocks will be needed. That depends on the implementation of the hwmod DTification (see next point)
* Remove the hwmod DT hack
This depends on some future work merging hwmod data into DT.
[0] https://lkml.org/lkml/2013/10/6/127
[1] https://git.kernel.org/cgit/linux/kernel/git/sre/linux-hsi.git/
-- Sebastian
Sebastian Reichel (11):
HSI: method to unregister clients from an hsi port
HSI: hsi-char: add Device Tree support
HSI: hsi-char: fix driver for multiport scenarios
ARM: OMAP2+: HSI: Introduce OMAP SSI driver
Documentation: DT: omap-ssi binding documentation
misc: Introduce Nokia CMT driver
Documentation: DT: nokia-cmt binding documentation
HSI: Introduce driver for SSI Protocol
DTS: ARM: OMAP3-N900: Add SSI support
DTS: ARM: OMAP3-N900: Add CMT support
DTS: ARM: OMAP3-N900: Add SSI protocol support
Documentation/devicetree/bindings/hsi/omap_ssi.txt | 69 + .../devicetree/bindings/misc/nokia-cmt.txt | 28 + arch/arm/boot/dts/omap3-n900.dts | 72 + arch/arm/boot/dts/omap3.dtsi | 47 + drivers/hsi/Kconfig | 1 + drivers/hsi/Makefile | 1 + drivers/hsi/clients/Kconfig | 8 + drivers/hsi/clients/Makefile | 3 +- drivers/hsi/clients/hsi_char.c | 13 +- drivers/hsi/clients/ssi_protocol.c | 1201 +++++++++++++++++ drivers/hsi/controllers/Kconfig | 19 + drivers/hsi/controllers/Makefile | 6 + drivers/hsi/controllers/omap_ssi.c | 619 +++++++++ drivers/hsi/controllers/omap_ssi.h | 166 +++ drivers/hsi/controllers/omap_ssi_port.c | 1401 ++++++++++++++++++++ drivers/hsi/controllers/omap_ssi_regs.h | 171 +++ drivers/hsi/hsi.c | 10 + drivers/misc/Kconfig | 7 + drivers/misc/Makefile | 1 + drivers/misc/nokia-cmt.c | 298 +++++ include/linux/hsi/hsi.h | 1 + include/linux/hsi/ssi_protocol.h | 41 + include/linux/nokia-cmt.h | 46 + 23 files changed, 4227 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/hsi/omap_ssi.txt create mode 100644 Documentation/devicetree/bindings/misc/nokia-cmt.txt create mode 100644 drivers/hsi/clients/ssi_protocol.c create mode 100644 drivers/hsi/controllers/Kconfig create mode 100644 drivers/hsi/controllers/Makefile create mode 100644 drivers/hsi/controllers/omap_ssi.c create mode 100644 drivers/hsi/controllers/omap_ssi.h create mode 100644 drivers/hsi/controllers/omap_ssi_port.c create mode 100644 drivers/hsi/controllers/omap_ssi_regs.h create mode 100644 drivers/misc/nokia-cmt.c create mode 100644 include/linux/hsi/ssi_protocol.h create mode 100644 include/linux/nokia-cmt.h
Signature · 6 lines
1.8.5.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC v4 1/11 HSI: method to unregister clients from an hsi port
This exports a method to unregister all clients from an hsi port.
--- drivers/hsi/hsi.c | 10 ++++++++++ include/linux/hsi/hsi.h | 1 + 2 files changed, 11 insertions(+)
drivers/hsi/hsi.c +10 -0
@@ -198,6 +198,16 @@ static void hsi_port_release(struct device *dev) }/** +* hsi_unregister_port - Unregister an HSI port +* @port: The HSI port to unregister +*/ +void hsi_port_unregister_clients (struct hsi_port *port) +{ +device_for_each_child (&port->device,NULL , hsi_remove_client); +} +EXPORT_SYMBOL_GPL (hsi_port_unregister_clients); + +/** * hsi_unregister_controller - Unregister an HSI controller * @hsi: The HSI controller to register */
include/linux/hsi/hsi.h +1 -0
@@ -284,6 +284,7 @@ int hsi_register_controller(struct hsi_controller *hsi);void hsi_unregister_controller (struct hsi_controller *hsi);void hsi_add_clients_from_dt (struct hsi_port *port,struct device_node *clients); +void hsi_port_unregister_clients (struct hsi_port *port);static inline void hsi_controller_set_drvdata (struct hsi_controller *hsi,void *data)
Signature · 1 line
1.8.5.1
RFC v4 2/11 HSI: hsi-char: add Device Tree support
In reply to Sebastian ReichelAdd of_match_table to hsi_char driver, so that it can be referenced from Device Tree.
--- drivers/hsi/clients/hsi_char.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/hsi/clients/hsi_char.c +11 -0
@@ -42,6 +42,7 @@#include <linux/stat.h> #include <linux/hsi/hsi.h> #include <linux/hsi/hsi_char.h> +#include <linux/of_device.h> #define HSC_DEVS 16/* Num of channels */ #define HSC_MSGS 4
@@ -758,12 +759,22 @@ static int hsc_remove(struct device *dev)return 0 ; } +#ifdef CONFIG_OF +static const struct of_device_id hsi_char_of_match[] = { + { .compatible ="ssi-char" , }, + { .compatible ="hsi-char" , }, + {}, +}; +MODULE_DEVICE_TABLE (of, hsi_char_of_match); +#endif +static struct hsi_client_driver hsc_driver = { .driver = { .name ="hsi_char" , .owner =THIS_MODULE , .probe = hsc_probe, .remove = hsc_remove, + .of_match_table =of_match_ptr (hsi_char_of_match), }, };
Signature · 1 line
1.8.5.1
RFC v4 3/11 HSI: hsi-char: fix driver for multiport scenarios
In reply to Sebastian ReichelFix return code check of alloc_chrdev_region, which returns 0 on success.
--- drivers/hsi/clients/hsi_char.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hsi/clients/hsi_char.c +1 -1
@@ -706,7 +706,7 @@ static int hsc_probe(struct device *dev)if (!hsc_major) { ret =alloc_chrdev_region (&hsc_dev, hsc_baseminor,HSC_DEVS , devname); -if (ret >0 ) +if (ret ==0 ) hsc_major =MAJOR (hsc_dev); }else { hsc_dev =MKDEV (hsc_major, hsc_baseminor);
Signature · 1 line
1.8.5.1
RFC v4 4/11 ARM: OMAP2+: HSI: Introduce OMAP SSI driver
In reply to Sebastian ReichelAdd OMAP SSI driver to the HSI subsystem.
The Synchronous Serial Interface (SSI) is a legacy version of HSI. As in the case of HSI, it is mainly used to connect Application engines (APE) with cellular modem engines (CMT) in cellular handsets.
It provides a multichannel, full-duplex, multi-core communication with no reference clock. The OMAP SSI block is capable of reaching speeds of 110 Mbit/s.
--- drivers/hsi/Kconfig | 1 + drivers/hsi/Makefile | 1 + drivers/hsi/controllers/Kconfig | 19 + drivers/hsi/controllers/Makefile | 6 + drivers/hsi/controllers/omap_ssi.c | 619 ++++++++++++++ drivers/hsi/controllers/omap_ssi.h | 166 ++++ drivers/hsi/controllers/omap_ssi_port.c | 1401 +++++++++++++++++++++++++++++++ drivers/hsi/controllers/omap_ssi_regs.h | 171 ++++ 8 files changed, 2384 insertions(+) create mode 100644 drivers/hsi/controllers/Kconfig create mode 100644 drivers/hsi/controllers/Makefile create mode 100644 drivers/hsi/controllers/omap_ssi.c create mode 100644 drivers/hsi/controllers/omap_ssi.h create mode 100644 drivers/hsi/controllers/omap_ssi_port.c create mode 100644 drivers/hsi/controllers/omap_ssi_regs.h
drivers/hsi/Kconfig +1 -0
@@ -14,6 +14,7 @@ config HSI_BOARDINFO bool default y +source "drivers/hsi/controllers/Kconfig" source "drivers/hsi/clients/Kconfig" endif # HSI
drivers/hsi/Makefile +1 -0
@@ -3,4 +3,5 @@ # obj-$(CONFIG_HSI_BOARDINFO) += hsi_boardinfo.o obj-$(CONFIG_HSI) += hsi.o +obj-y += controllers/ obj-y += clients/
drivers/hsi/controllers/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +# +# HSI controllers configuration +# +comment "HSI controllers" + +config OMAP_SSI + tristate "OMAP SSI hardware driver" + depends on ARCH_OMAP && HSI + ---help--- + SSI is a legacy version of HSI. It is usually used to connect + an application engine with a cellular modem. + If you say Y here, you will enable the OMAP SSI hardware driver. + + If unsure, say N. + +config OMAP_SSI_PORT + tristate + default m if OMAP_SSI=m + default y if OMAP_SSI=y
drivers/hsi/controllers/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# +# Makefile for HSI controllers drivers +# + +obj-$(CONFIG_OMAP_SSI) += omap_ssi.o +obj-$(CONFIG_OMAP_SSI_PORT) += omap_ssi_port.o
drivers/hsi/controllers/omap_ssi.c new file +619 -0
619 lines not on this page · raw message
drivers/hsi/controllers/omap_ssi.h new file +166 -0
166 lines not on this page · raw message
drivers/hsi/controllers/omap_ssi_port.c new file +1401 -0
1,401 lines not on this page · raw message
drivers/hsi/controllers/omap_ssi_regs.h new file +171 -0
171 lines not on this page · raw message
Signature · 1 line
1.8.5.1
RFC v4 5/11 Documentation: DT: omap-ssi binding documentation
In reply to Sebastian ReichelCreate device tree binding documentation for
OMAP Synchronous Serial Interface (SSI) device.
--- Documentation/devicetree/bindings/hsi/omap_ssi.txt | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/hsi/omap_ssi.txt
Documentation/devicetree/bindings/hsi/omap_ssi.txt new file +69 -0
@@ -0,0 +1,69 @@ +OMAP SSI controller bindings + +Required properties: +- compatible: Should include "ti,omap3-ssi". +- reg-names: Contains the values "sys" and "gdd". +- reg: Contains a register specifier for each entry in + reg-names. +- interrupt-names: Contains the value "gdd_mpu". +- interrupts: Contains interrupt information for each entry in + interrupt-names. +- ranges Represents the bus address mapping between the main + controller node and the child nodes below. +- #address-cells Should be set to <1> +- #size-cells Should be set to <1> + +Each port is represented as a sub-node of the ti,omap3-ssi device. + +Required Port sub-node properties: +- compatible: Should be set to the following value + ti,omap3-ssi-port (applicable to OMAP34xx devices) +- reg-names: Contains the values "rx" and "tx". +- reg: Contains a register specifier for each entry in + reg-names. +- interrupt-parent Should be a phandle for the interrupt controller +- interrupt-names: Contains the values "mpu_irq0" and "mpu_irq1". +- interrupts: Contains interrupt information for each entry in + interrupt-names. +- ti,ssi-cawake-gpio: Defines which GPIO pin is used to signify CAWAKE + events for the port. This is an optional board-specific + property. If it's missing the port will not be + enabled. + +Example for Nokia N900: + +ssi-controller@48058000 { + compatible = "ti,omap3-ssi"; + + /* needed until hwmod is updated to use the compatible string */ + ti,hwmods = "ssi"; + + reg = <0x48058000 0x1000>, + <0x48059000 0x1000>; + reg-names = "sys", + "gdd"; + + interrupts = <55>; + interrupt-names = "gdd_mpu"; + + #address-cells = <1>; + #size-cells = <1>; + ranges; + + ssi-port@0 { + compatible = "ti,omap3-ssi-port"; + + reg = <0x4805a000 0x800>, + <0x4805a800 0x800>; + reg-names = "tx", + "rx"; + + interrupt-parent = <&intc>; + interrupts = <51>, + <52>; + interrupt-names = "mpu_irq0", + "mpu_irq1"; + + ti,ssi-cawake-gpio = <&gpio5 23 GPIO_ACTIVE_HIGH>; /* 151 */ + } +}
Signature · 1 line
1.8.5.1
Re: [RFCv4 05/11] Documentation: DT: omap-ssi binding documentation
Quoted 15 lines · Sebastian Reichel
Create device tree binding documentation for
OMAP Synchronous Serial Interface (SSI) device.Signed-off-by Sebastian Reichel <[email protected]>--- Documentation/devicetree/bindings/hsi/omap_ssi.txt | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/hsi/omap_ssi.txtDocumentation/devicetree/bindings/hsi/omap_ssi.txt new file +0
-0
Documentation/devicetree/bindings/hsi/omap_ssi.txt line 5
Quoted 5 lines
Documentation/devicetree/bindings/hsi/omap_ssi.txt new file +5
-0@@ -0,0 +1,69 @@ +OMAP SSI controller bindings + +Required properties: +- compatible: Should include "ti,omap3-ssi". +- reg-names: Contains the values "sys" and "gdd".
Do you need the reg-names? The order won't change so you can just document the order in the binding?
Documentation/devicetree/bindings/hsi/omap_ssi.txt line 8
Quoted 3 lines
Documentation/devicetree/bindings/hsi/omap_ssi.txt new file +3
-0+- reg: Contains a register specifier for each entry in + reg-names. +- interrupt-names: Contains the value "gdd_mpu".
Maybe interrupt-names are not needed either?
Documentation/devicetree/bindings/hsi/omap_ssi.txt line 21
Quoted 13 lines
Documentation/devicetree/bindings/hsi/omap_ssi.txt new file +13
-0+- interrupts: Contains interrupt information for each entry in + interrupt-names. +- ranges Represents the bus address mapping between the main + controller node and the child nodes below. +- #address-cells Should be set to <1> +- #size-cells Should be set to <1> + +Each port is represented as a sub-node of the ti,omap3-ssi device. + +Required Port sub-node properties: +- compatible: Should be set to the following value + ti,omap3-ssi-port (applicable to OMAP34xx devices) +- reg-names: Contains the values "rx" and "tx".
Here too?
Documentation/devicetree/bindings/hsi/omap_ssi.txt line 25
Quoted 4 lines
Documentation/devicetree/bindings/hsi/omap_ssi.txt new file +4
-0+- reg: Contains a register specifier for each entry in + reg-names. +- interrupt-parent Should be a phandle for the interrupt controller +- interrupt-names: Contains the values "mpu_irq0" and "mpu_irq1".
And here?
Documentation/devicetree/bindings/hsi/omap_ssi.txt line 31
Quoted 6 lines
Documentation/devicetree/bindings/hsi/omap_ssi.txt new file +6
-0+- interrupts: Contains interrupt information for each entry in + interrupt-names. +- ti,ssi-cawake-gpio: Defines which GPIO pin is used to signify CAWAKE + events for the port. This is an optional board-specific + property. If it's missing the port will not be + enabled.
Hmm this might be just a wake-up GPIO? If so, you should be able to just set it up as an interrupt and do a request_irq on the pinctrl-single entry for it.
It might even be one of the already mapped interrupt lines that the code is remuxing to a GPIO for idle? If so, then you can just use the new binding for interrupts-extended to handle the wake-up events.
If you post the GPIO number for ti,ssi-cawake-gpio and the interrupt numbers I can check if there's a need to handle it separately as a GPIO pin or if it already can be automatically handled for the wake-up events.
Regards,
Tony
Re: [RFCv4 05/11] Documentation: DT: omap-ssi binding documentation
Hi Tony,
Quoted 6 lines · Tony Lindgren
Quoted 3 lines
+Required properties:
+- compatible: Should include "ti,omap3-ssi". +- reg-names: Contains the values "sys" and "gdd".Do you need the reg-names? The order won't change so you can just document the order in the binding?
The names are not needed, but I like self-documenting code/bindings.
Also the examples in Documentation/devicetree/bindings/resource-names.txt look similar to this case.
What do you have against the -names properties?
The same statement goes for the following -names comments, so I will skip them ;)
Quoted 9 lines
[...]
Documentation/devicetree/bindings/hsi/omap_ssi.txt line 31
Quoted 4 lines
+- ti,ssi-cawake-gpio: Defines which GPIO pin is used to signify CAWAKE
Documentation/devicetree/bindings/hsi/omap_ssi.txt new file +3
-0+ events for the port. This is an optional board-specific + property. If it's missing the port will not be + enabled.Hmm this might be just a wake-up GPIO? If so, you should be able to just set it up as an interrupt and do a
request_irqon the pinctrl-single entry for it.
Yes, this gpio is used as interrupt in the driver, but its also read directly. I already considered making it an irq in the DT data (since its mainly used as irq), but I could not find out how to read the current status of an irq line.
Quoted 7 lines
It might even be one of the already mapped interrupt lines that the code is remuxing to a GPIO for idle? If so, then you can just use the new binding for interrupts-extended to handle the wake-up events.
If you post the GPIO number for ti,ssi-cawake-gpio and the interrupt numbers I can check if there's a need to handle it separately as a GPIO pin or if it already can be automatically handled for the wake-up events.
You can see it in one of the next patches, which adds the needed nodes in omap3-n900.dts. The used GPIO on N900 is 151 (gpio5 23) and I use the following pinmux configuration:
0x152 (PIN_INPUT | WAKEUP_EN | MUX_MODE4)
P.S.: I intend to get this into 3.15. Before I will send an updated
series, which uses the omap clock DT bindings as requested by DT binding maintainers.
-- Sebastian
RFC v4 6/11 misc: Introduce Nokia CMT driver
In reply to Sebastian ReichelAdd driver handling GPIO pins of Nokia modems. The driver provides reset notifications, so that SSI clients can subscribe to them easily.
--- drivers/misc/Kconfig | 7 ++ drivers/misc/Makefile | 1 + drivers/misc/nokia-cmt.c | 298 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/nokia-cmt.h | 46 +++++++ 4 files changed, 352 insertions(+) create mode 100644 drivers/misc/nokia-cmt.c create mode 100644 include/linux/nokia-cmt.h
drivers/misc/Kconfig +7 -0
@@ -515,6 +515,13 @@ config SRAM the genalloc API. It is supposed to be used for small on-chip SRAM areas found on many SoCs. +config NOKIA_CMT + tristate "Enable CMT support" + help + If you say Y here, you will enable CMT support. + + If unsure, say Y, or else you will not be able to use the CMT. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -53,3 +53,4 @@ obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o obj-$(CONFIG_SRAM) += sram.o obj-y += mic/ +obj-$(CONFIG_NOKIA_CMT) += nokia-cmt.o
drivers/misc/nokia-cmt.c new file +298 -0
298 lines not on this page · raw message
include/linux/nokia-cmt.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
1.8.5.1
Re: [RFCv4 06/11] misc: Introduce Nokia CMT driver
Quoted 5 lines · Sebastian Reichel
Add driver handling GPIO pins of Nokia modems. The driver provides reset notifications, so that SSI clients can subscribe to them easily.
Signed-off-by Sebastian Reichel <[email protected]>
If the driver provides reset notifications, should it rather be in drivers/reset?
I'm thinking of a generic GPIO reset driver with a generic notification mechanism, which seems to be what this is.
I.e. it doesn't look device-specific at all, just like some generic glue code that could be useful to many such scenarios.
drivers/misc/Kconfig config SRAM · line 523
Quoted 6 lines
drivers/misc/Kconfig +6
-0+config NOKIA_CMT + tristate "Enable CMT support" + help + If you say Y here, you will enable CMT support. + + If unsure, say Y, or else you will not be able to use the CMT.
None of this explains what this driver actually does and what CMT means, so please rewrite this a bit to be more helpful. The way it is written it could as well say "enable FOO support".
drivers/misc/nokia-cmt.c line 2
Quoted 4 lines
+++
b/drivers/misc/nokia-cmt.cdrivers/misc/nokia-cmt.c new file +2
-0@@ -0,0 +1,298 @@ +/* +* CMT support.
So CMT = ...?
Quoted 7 lines
drivers/misc/nokia-cmt.c new file +7
-0+/** +* struct cmt_device - CMT device data +* @cmt_rst_ind_tasklet: Bottom half for CMT reset line events +* @cmt_rst_ind_irq: IRQ number of the CMT reset line +* @n_head: List of notifiers registered to get CMT events +* @node: Link on the list of available CMTs +* @device: Reference to the CMT platform device
drivers/misc/nokia-cmt.c line 66
Quoted 10 lines
drivers/misc/nokia-cmt.c new file +10
-0+*/ +struct cmt_device { +struct tasklet_struct cmt_rst_ind_tasklet; +unsigned int cmt_rst_ind_irq; +struct atomic_notifier_head n_head; +struct list_head node; +struct device *device; +struct cmt_gpio *gpios; +int gpio_amount; +};
The kerneldoc and and the struct are not in sync. Look this over.
Quoted 1 line
drivers/misc/nokia-cmt.c new file +1
-0+static LIST_HEAD (cmt_list);/* List of CMT devices */
(...)
drivers/misc/nokia-cmt.c line 120
Quoted 13 lines
drivers/misc/nokia-cmt.c new file +13
-0+struct cmt_device *cmt_get (const char *name) +{ +struct cmt_device *p, *cmt =ERR_PTR (-ENODEV ); + +list_for_each_entry (p, &cmt_list, node) +if (strcmp (name,dev_name (p->device)) ==0 ) { + cmt = p; +break ; + } + +return cmt; +} +EXPORT_SYMBOL_GPL (cmt_get);
Is this driver used on non-DT platforms, or can we skip this struct device * referencing altogether?
I would feel better if this driver looked more like drivers/mfd/syscon.c
drivers/misc/nokia-cmt.c line 163
Quoted 8 lines
drivers/misc/nokia-cmt.c new file +8
-0+static irqreturn_t cmt_rst_ind_isr (int irq,void *cmtdev) +{ +struct cmt_device *cmt = (struct cmt_device *)cmtdev; + +tasklet_schedule (&cmt->cmt_rst_ind_tasklet); + +return IRQ_HANDLED ; +}
Why are you using a tasklet rather than a work
for this?
Yours,
Linus Walleij
Re: [RFCv4 06/11] misc: Introduce Nokia CMT driver
Hi Linus,
Quoted 10 lines · Linus Walleij
Quoted 5 lines · Sebastian Reichel
Add driver handling GPIO pins of Nokia modems. The driver provides reset notifications, so that SSI clients can subscribe to them easily.
Signed-off-by Sebastian Reichel <[email protected]>If the driver provides reset notifications, should it rather be in
drivers/reset?
Quoted 6 lines
I'm thinking of a generic GPIO reset driver with a generic notification mechanism, which seems to be what this is.
I.e. it doesn't look device-specific at all, just like some generic glue code that could be useful to many such scenarios.
I like the idea.
Probably the remaining gpio exporting code can be converted into some generic gpio-sysfs-export driver as well.
What do you think about the following?
/*
* driver, which provides generic reset notifications */
cmt_reset: reset-notifier {
compatible = "linux,reset-notification";
interrupts = <gpio>;
};/*
* driver, which exports the specified gpios in sysfs with the
* supplied names. The device will be named according to the
* label
*/
cmt_gpios: gpio-sysfs-export {
compatible = "linux,gpio-sysfs-export";
label = "nokia-cmt";
gpios = <A>, <B>, ...;
gpio-names = "A", "B", ...;
};Quoted 10 lines
drivers/misc/Kconfig config SRAM · line 523
Quoted 6 lines
drivers/misc/Kconfig +6
-0+config NOKIA_CMT + tristate "Enable CMT support" + help + If you say Y here, you will enable CMT support. + + If unsure, say Y, or else you will not be able to use the CMT.None of this explains what this driver actually does and what CMT means, so please rewrite this a bit to be more helpful. The way it is written it could as well say "enable FOO support".
I probably should have reviewed this better. This is the original text from Nokia's driver.
Quoted 6 lines
drivers/misc/nokia-cmt.c line 2
Quoted 4 lines
+++
b/drivers/misc/nokia-cmt.cdrivers/misc/nokia-cmt.c new file +2
-0@@ -0,0 +1,298 @@ +/* +* CMT support. So CMT = ...?
CMT = Cellular Modem
Quoted 12 lines
Quoted 12 lines
drivers/misc/nokia-cmt.c new file +12
-0+/** +* struct cmt_device - CMT device data +* @cmt_rst_ind_tasklet: Bottom half for CMT reset line events +* @cmt_rst_ind_irq: IRQ number of the CMT reset line +* @n_head: List of notifiers registered to get CMT events +* @node: Link on the list of available CMTs +* @device: Reference to the CMT platform device +*/ +struct cmt_device { +struct tasklet_struct cmt_rst_ind_tasklet; +unsigned int cmt_rst_ind_irq; +struct atomic_notifier_head n_head;
Quoted 8 lines
drivers/misc/nokia-cmt.c line 66
Quoted 5 lines
drivers/misc/nokia-cmt.c new file +5
-0+struct list_head node; +struct device *device; +struct cmt_gpio *gpios; +int gpio_amount; +};The kerneldoc and and the struct are not in sync. Look this over.
I will fix this in v5 (in case that its not removed completly).
Quoted 19 lines
Quoted 1 line
drivers/misc/nokia-cmt.c new file +1
-0+static LIST_HEAD (cmt_list);/* List of CMT devices */ (...)
drivers/misc/nokia-cmt.c line 120
Quoted 13 lines
drivers/misc/nokia-cmt.c new file +13
-0+struct cmt_device *cmt_get (const char *name) +{ +struct cmt_device *p, *cmt =ERR_PTR (-ENODEV ); + +list_for_each_entry (p, &cmt_list, node) +if (strcmp (name,dev_name (p->device)) ==0 ) { + cmt = p; +break ; + } + +return cmt; +} +EXPORT_SYMBOL_GPL (cmt_get);Is this driver used on non-DT platforms, or can we skip this struct device * referencing altogether?
Quoted 2 lines
I would feel better if this driver looked more like
drivers/mfd/syscon.c
Will be removed in v5.
Quoted 11 lines
drivers/misc/nokia-cmt.c line 163
Quoted 8 lines
drivers/misc/nokia-cmt.c new file +8
-0+static irqreturn_t cmt_rst_ind_isr (int irq,void *cmtdev) +{ +struct cmt_device *cmt = (struct cmt_device *)cmtdev; + +tasklet_schedule (&cmt->cmt_rst_ind_tasklet); + +return IRQ_HANDLED ; +}Why are you using a tasklet rather than a work
for this?
No particular reason. I just took this over from Nokia's code.
-- Sebastian
Re: [RFCv4 06/11] misc: Introduce Nokia CMT driver
Quoted 10 lines · Sebastian Reichel
Quoted 3 lines · Linus Walleij
I.e. it doesn't look device-specific at all, just like some generic glue code that could be useful to many such scenarios.
I like the idea.
Probably the remaining gpio exporting code can be converted into some generic gpio-sysfs-export driver as well.
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.)
Quoted 10 lines
What do you think about the following?
/*
* driver, which provides generic reset notifications */cmt_reset: reset-notifier { compatible = "linux,reset-notification"; interrupts = <gpio>; };
Looks good to me.
Quoted 5 lines
/*
* driver, which exports the specified gpios in sysfs with the
* supplied names. The device will be named according to the
* label
*/
Quoted 7 lines
cmt_gpios: gpio-sysfs-export {
compatible = "linux,gpio-sysfs-export";
label = "nokia-cmt";
gpios = <A>, <B>, ...;
gpio-names = "A", "B", ...;
};Please follow the discussion on this topic:
http://marc.info/?l=linux-gpio&m=138201170431416&w=2
Quoted 4 lines
Quoted 2 lines
Why are you using a tasklet rather than a work
for this?No particular reason. I just took this over from Nokia's code.
Can you try to use a work instead?
Yours,
Linus Walleij
Re: [RFCv4 06/11] misc: Introduce Nokia CMT driver
Hi,
Quoted 9 lines · Linus Walleij
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?
Quoted 8 lines
Quoted 8 lines
What do you think about the following?
/*
* driver, which provides generic reset notifications */cmt_reset: reset-notifier { compatible = "linux,reset-notification";
Quoted 4 lines
Quoted 2 lines
interrupts = <gpio>; };Looks good to me.
Ok :) I will prepare something for the next patch.
Quoted 9 lines
Quoted 9 lines
/*
* driver, which exports the specified gpios in sysfs with the
* supplied names. The device will be named according to the
* label
*/cmt_gpios: gpio-sysfs-export { compatible = "linux,gpio-sysfs-export"; label = "nokia-cmt";
Quoted 6 lines
Quoted 3 lines
gpios = <A>, <B>, ...; gpio-names = "A", "B", ...; };Please follow the discussion on this topic:
http://marc.info/?l=linux-gpio&m=138201170431416&w=2
Ok.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Why are you using a tasklet rather than a work
for this?No particular reason. I just took this over from Nokia's code.
Can you try to use a work instead?
Yes. I will have a look at this.
-- Sebastian
Re: Re: [RFCv4 06/11] misc: Introduce Nokia CMT driver
Quoted 16 lines · Sebastian Reichel
Hi,
Quoted 9 lines · Linus Walleij
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:
Quoted 7 lines
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.
Regards,
Ivo
Re: Re: [RFCv4 06/11] misc: Introduce Nokia CMT driver
Quoted 39 lines · Ivajlo Dimitrov
Quoted 14 lines · Linus Walleij
Quoted 9 lines
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:Quoted 7 lines
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?
Quoted 4 lines
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
Re: Re: [RFCv4 06/11] misc: Introduce Nokia CMT driver
Quoted 10 lines · Sebastian Reichel
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
Yes this looks like kernel code shoehorned into userspace. As it deals with suspending/resuming hardware for example, and that is something the kernel needs to coordinate and do uniformly across all devices (IMO).
A while back Arun Murthy was working on creating an embedded modem subsystem but the development stopped. However such a subsystem is a generic problem of general interest and this would be one of the candidates for drivers/modem I think. Sadly creating it may be a lot of work, I don't know exactly.
http://marc.info/?l=linux-kernel&m=135027904405680&w=2
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC v4 7/11 Documentation: DT: nokia-cmt binding documentation
In reply to Sebastian ReichelCreate device tree binding documentation for
Nokia cellular modem GPIO handling.
--- .../devicetree/bindings/misc/nokia-cmt.txt | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/nokia-cmt.txt
Documentation/devicetree/bindings/misc/nokia-cmt.txt new file +28 -0
@@ -0,0 +1,28 @@ +Nokia Cellular Modem (CMT) bindings + +Required properties: +- compatible: Should include "nokia,cmt". +- interrupts: Interrupt specifier for the cmt reset irq. +- gpio-names: Contains the values "cmt_apeslpx", "cmt_rst_rq", + "cmt_en", "cmt_rst" and "cmt_bsi". +- gpios: Contains gpio information for each entry in gpio-names. + +Example for Nokia N900: + +cmt: nokia-cmt { + compatible = "nokia,cmt"; + + interrupt-parent = <&gpio3>; + interrupts = <8 IRQ_TYPE_EDGE_FALLING>; /* gpio line 72 */ + + gpios = <&gpio3 6 GPIO_ACTIVE_HIGH>, /* 70 */ + <&gpio3 9 GPIO_ACTIVE_HIGH>, /* 73 */ + <&gpio3 10 GPIO_ACTIVE_HIGH>, /* 74 */ + <&gpio3 11 GPIO_ACTIVE_HIGH>, /* 75 */ + <&gpio5 29 GPIO_ACTIVE_HIGH>; /* 157 */ + gpio-names = "cmt_apeslpx", + "cmt_rst_rq", + "cmt_en", + "cmt_rst", + "cmt_bsi"; +};
Signature · 1 line
1.8.5.1
RFC v4 8/11 HSI: Introduce driver for SSI Protocol
In reply to Sebastian ReichelThis adds a driver for the SSI McSAAB protocol as used in the Nokia N900.
--- drivers/hsi/clients/Kconfig | 8 + drivers/hsi/clients/Makefile | 3 +- drivers/hsi/clients/ssi_protocol.c | 1201 ++++++++++++++++++++++++++++++++++++ include/linux/hsi/ssi_protocol.h | 41 ++ 4 files changed, 1252 insertions(+), 1 deletion(-) create mode 100644 drivers/hsi/clients/ssi_protocol.c create mode 100644 include/linux/hsi/ssi_protocol.h
drivers/hsi/clients/Kconfig +8 -0
@@ -4,6 +4,14 @@ comment "HSI clients" +config SSI_PROTOCOL + tristate "SSI protocol" + depends on HSI && OMAP_SSI && NOKIA_CMT && PHONET + help + If you say Y here, you will enable the SSI protocol aka McSAAB. + + If unsure, say N. + config HSI_CHAR tristate "HSI/SSI character driver" depends on HSI
drivers/hsi/clients/Makefile +2 -1
@@ -2,4 +2,5 @@ # Makefile for HSI clients # -obj-$(CONFIG_HSI_CHAR) += hsi_char.o +obj-$(CONFIG_SSI_PROTOCOL) += ssi_protocol.o +obj-$(CONFIG_HSI_CHAR) += hsi_char.o
drivers/hsi/clients/ssi_protocol.c new file +1201 -0
1,201 lines not on this page · raw message
include/linux/hsi/ssi_protocol.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
1.8.5.1
RFC v4 9/11 DTS: ARM: OMAP3-N900: Add SSI support
In reply to Sebastian ReichelAdd SSI device tree data for OMAP3 and Nokia N900.
--- arch/arm/boot/dts/omap3-n900.dts | 28 ++++++++++++++++++++++++ arch/arm/boot/dts/omap3.dtsi | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+)
arch/arm/boot/dts/omap3-n900.dts +28 -0
@@ -145,6 +145,19 @@ 0x0d4 (PIN_OUTPUT | MUX_MODE4) /* RX51_LCD_RESET_GPIO */ >; }; + + ssi_pins: pinmux_ssi { + pinctrl-single,pins = < + 0x150 (PIN_INPUT_PULLUP | MUX_MODE1) /* ssi1_rdy_tx */ + 0x14e (PIN_OUTPUT | MUX_MODE1) /* ssi1_flag_tx */ + 0x152 (PIN_INPUT | WAKEUP_EN | MUX_MODE4) /* ssi1_wake_tx (cawake) */ + 0x14c (PIN_OUTPUT | MUX_MODE1) /* ssi1_dat_tx */ + 0x154 (PIN_INPUT | MUX_MODE1) /* ssi1_dat_rx */ + 0x156 (PIN_INPUT | MUX_MODE1) /* ssi1_flag_rx */ + 0x158 (PIN_OUTPUT | MUX_MODE1) /* ssi1_rdy_rx */ + 0x15a (PIN_OUTPUT | MUX_MODE1) /* ssi1_wake */ + >; + }; }; &i2c1 {
@@ -490,6 +503,21 @@ power = <50>; }; +&ssi_port1 { + pinctrl-names = "default"; + pinctrl-0 = <&ssi_pins>; + + ti,ssi-cawake-gpio = <&gpio5 23 GPIO_ACTIVE_HIGH>; /* 151 */ + + ssi-char { + compatible = "ssi-char"; + }; +}; + +&ssi_port2 { + status = "disabled"; +}; + &uart1 { status = "disabled"; };
arch/arm/boot/dts/omap3.dtsi +47 -0
52 lines not on this page · raw message
Signature · 1 line
1.8.5.1
RFC v4 10/11 DTS: ARM: OMAP3-N900: Add CMT support
In reply to Sebastian ReichelThis adds support for the Nokia N900 cellular modem.
--- arch/arm/boot/dts/omap3-n900.dts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
arch/arm/boot/dts/omap3-n900.dts +31 -0
@@ -74,6 +74,26 @@ }; }; + cmt: nokia-cmt { + compatible = "nokia,cmt"; + + pinctrl-names = "default"; + pinctrl-0 = <&cmt_pins>; + + interrupt-parent = <&gpio3>; + interrupts = <8 IRQ_TYPE_EDGE_FALLING>; /* gpio line 72 */ + + gpios = <&gpio3 6 GPIO_ACTIVE_HIGH>, /* 70 */ + <&gpio3 9 GPIO_ACTIVE_HIGH>, /* 73 */ + <&gpio3 10 GPIO_ACTIVE_HIGH>, /* 74 */ + <&gpio3 11 GPIO_ACTIVE_HIGH>, /* 75 */ + <&gpio5 29 GPIO_ACTIVE_HIGH>; /* 157 */ + gpio-names = "cmt_apeslpx", + "cmt_rst_rq", + "cmt_en", + "cmt_rst", + "cmt_bsi"; + }; }; &omap3_pmx_core {
@@ -158,6 +178,17 @@ 0x15a (PIN_OUTPUT | MUX_MODE1) /* ssi1_wake */ >; }; + + cmt_pins: pinmux_cmt { + pinctrl-single,pins = < + 0x0ac (PIN_OUTPUT | MUX_MODE4) /* gpio 70 => cmt_apeslpx */ + 0x0b0 (PIN_INPUT | WAKEUP_EN | MUX_MODE4) /* gpio 72 => ape_rst_rq */ + 0x0b2 (PIN_OUTPUT | MUX_MODE4) /* gpio 73 => cmt_rst_rq */ + 0x0b4 (PIN_OUTPUT | MUX_MODE4) /* gpio 74 => cmt_en */ + 0x0b6 (PIN_OUTPUT | MUX_MODE4) /* gpio 75 => cmt_rst */ + 0x15e (PIN_OUTPUT | MUX_MODE4) /* gpio 157 => cmt_bsi */ + >; + }; }; &i2c1 {
Signature · 1 line
1.8.5.1
RFC v4 11/11 DTS: ARM: OMAP3-N900: Add SSI protocol support
In reply to Sebastian ReichelThis adds support for the protocol used to communicate with its cellular modem.
--- arch/arm/boot/dts/omap3-n900.dts | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/arm/boot/dts/omap3-n900.dts +13 -0
@@ -534,6 +534,7 @@ power = <50>; }; +#include <dt-bindings/hsi/hsi.h> &ssi_port1 { pinctrl-names = "default"; pinctrl-0 = <&ssi_pins>;
@@ -543,6 +544,18 @@ ssi-char { compatible = "ssi-char"; }; + + ssi-protocol { + compatible = "ssi-protocol"; + + hsi,mode = <HSI_MODE_FRAME>; + hsi,channels = <4>; + hsi,speed = <55000>; + hsi,flow = <HSI_FLOW_SYNC>; + hsi,arb_mode = <HSI_ARB_RR>; + + nokia,cmt = <&cmt>; + }; }; &ssi_port2 {
Signature · 1 line
1.8.5.1