Skip to contentSkip to conversation

OMAP SSI driver

RFC PATCH Superseded Sebastian Reichel 4 participants 15 messages Aug 11, 2013 – Aug 26, 2013

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover OMAP SSI driver

Hi !

This patchset adds an OMAP SSI driver to the HSI framework.

After leaving Nokia Carlos Chinea had no more time to work on this patchset; Thus I tried updating the driver to fix the mentioned issues.

I applied the following changes to the last patch from Carlos:

* convert driver to use hwmod and add SSI information to hwmod database
* convert driver to use runtime_pm
* change platform data, so that it forwards the wake_gpio to avoid irq_to_gpio
* move the ssi.h and rename to hsi-omap-ssi.h (multiplatform support)

The code compiles and is initialized on the RX51. I also verified, that it does not break the boot on my Pandaboard.

The driver has been written by Carlos Chinea and has already been sent for public review as part of the HSI framework RFC before:

https://lkml.org/lkml/2011/6/10/280

-- Sebastian

Sebastian Reichel (3):
ARM: OMAP2+: hwmod-data: Add SSI information
ARM: OMAP2+: HSI: Introduce OMAP SSI driver
ARM: OMAP2+: Add SSI driver configuration

 arch/arm/mach-omap2/Makefile                 |    4 +
 arch/arm/mach-omap2/board-rx51-peripherals.c |   10 +-
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c   |  104 ++
 arch/arm/mach-omap2/ssi.c                    |   82 ++
 drivers/hsi/Kconfig                          |    1 +
 drivers/hsi/Makefile                         |    1 +
 drivers/hsi/controllers/Kconfig              |   23 +
 drivers/hsi/controllers/Makefile             |    5 +
 drivers/hsi/controllers/omap_ssi.c           | 1879 ++++++++++++++++++++++++++
 include/linux/platform_data/hsi-omap-ssi.h   |  202 +++
 10 files changed, 2310 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-omap2/ssi.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 include/linux/platform_data/hsi-omap-ssi.h
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/3 ARM: OMAP2+: hwmod-data: Add SSI information

From: Sebastian Reichel <[email protected]>

This patch adds Synchronous Serial Interface (SSI) hwmod support for OMAP34xx SoCs.

---
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |  104 ++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +104 -0
index 0c3a427..74006c4 100644
@@ -3693,6 +3693,109 @@ static struct omap_hwmod_ocp_if omap3xxx_l4_core__aes = {
 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
 };
 
+/*
+ * 'ssi' class
+ * synchronous serial interface (multichannel and full-duplex serial if)
+ */
+
+static struct omap_hwmod_class_sysconfig omap34xx_ssi_sysc = {
+	.rev_offs	= 0x0000,
+	.sysc_offs	= 0x0010,
+	.syss_offs	= 0x0014,
+	.sysc_flags	= (SYSC_HAS_AUTOIDLE | SYSC_HAS_EMUFREE |
+			   SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE |
+			   SYSC_HAS_SOFTRESET | SYSS_HAS_RESET_STATUS),
+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+			   SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO |
+			   MSTANDBY_SMART | MSTANDBY_SMART_WKUP),
+	.sysc_fields	= &omap_hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class omap34xx_ssi_hwmod_class = {
+	.name	= "ssi",
+	.sysc	= &omap34xx_ssi_sysc,
+};
+
+static struct omap_hwmod_irq_info omap34xx_ssi_irqs[] = {
+	{ .name = "ssi_p1_mpu_irq0", .irq = 67 },
+	{ .name = "ssi_p1_mpu_irq1", .irq = 68 },
+	{ .name = "ssi_p2_mpu_irq0", .irq = 69 },
+	{ .name = "ssi_p2_mpu_irq1", .irq = 70 },
+	{ .name = "ssi_gdd_mpu",     .irq = 71 },
+	{ .irq = -1 },
+};
+
+static struct omap_hwmod_addr_space omap34xx_ssi_addrs[] = {
+	{
+		.name		= "sys",
+		.pa_start	= 0x48058000,
+		.pa_end		= 0x48058fff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* generic distributed DMA */
+		.name		= "gdd",
+		.pa_start	= 0x48059000,
+		.pa_end		= 0x48059fff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 1: synchronous serial transmitter */
+		.name		= "p1_sst",
+		.pa_start	= 0x4805a000,
+		.pa_end		= 0x4805a7ff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 1: synchronous serial receiver */
+		.name		= "p1_ssr",
+		.pa_start	= 0x4805a800,
+		.pa_end		= 0x4805afff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 2: synchronous serial transmitter */
+		.name		= "p2_sst",
+		.pa_start	= 0x4805b000,
+		.pa_end		= 0x4805b7ff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 2: synchronous serial receiver */
+		.name		= "p2_ssr",
+		.pa_start	= 0x4805b800,
+		.pa_end		= 0x4805bfff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{}
+};
+
+static struct omap_hwmod omap34xx_ssi_hwmod = {
+	.name		= "ssi",
+	.class		= &omap34xx_ssi_hwmod_class,
+	.clkdm_name	= "l3_init_clkdm",
+	.mpu_irqs	= omap34xx_ssi_irqs,
+	.main_clk	= "ssi_ssr_fck",
+	.prcm		= {
+		.omap2 = {
+			.prcm_reg_id		= 1,
+			.module_bit		= OMAP3430_EN_SSI_SHIFT,
+			.module_offs		= WKUP_MOD,
+			.idlest_reg_id		= 1,
+			.idlest_idle_bit	= OMAP3430ES2_ST_SSI_IDLE_SHIFT,
+		},
+	},
+};
+
+/* SSI -> l3 */
+static struct omap_hwmod_ocp_if omap34xx_l3__ssi = {
+	.master		= &omap3xxx_l3_main_hwmod,
+	.slave		= &omap34xx_ssi_hwmod,
+	.clk		= "ssi_ick",
+	.addr		= omap34xx_ssi_addrs,
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
+
 static struct omap_hwmod_ocp_if *omap3xxx_hwmod_ocp_ifs[] __initdata = {
 	&omap3xxx_l3_main__l4_core,
 	&omap3xxx_l3_main__l4_per,
@@ -3818,6 +3921,7 @@ static struct omap_hwmod_ocp_if *omap34xx_hwmod_ocp_ifs[] __initdata = {
 #ifdef CONFIG_OMAP_IOMMU_IVA2
 	&omap3xxx_l3_main__mmu_iva,
 #endif
+	&omap34xx_l3__ssi,
 	NULL
 };
 
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/3 ARM: OMAP2+: HSI: Introduce OMAP SSI driver

From: Sebastian Reichel <[email protected]>

This patch adds an OMAP SSI driver to the HSI framework.

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            |   23 +
 drivers/hsi/controllers/Makefile           |    5 +
 drivers/hsi/controllers/omap_ssi.c         | 1879 ++++++++++++++++++++++++++++
 include/linux/platform_data/hsi-omap-ssi.h |  202 +++
 6 files changed, 2111 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 include/linux/platform_data/hsi-omap-ssi.h
drivers/hsi/Kconfig +1 -0
index d94e38d..2c76de4 100644
@@ -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
index 9d5d33f..360371e 100644
@@ -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 +23 -0
new file mode 100644
index 0000000..3efe0f0
@@ -0,0 +1,23 @@
+#
+# HSI controllers configuration
+#
+comment "HSI controllers"
+
+config OMAP_SSI
+	tristate "OMAP SSI hardware driver"
+	depends on ARCH_OMAP && HSI
+	default n
+	---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.
+
+if OMAP_SSI
+
+config OMAP_SSI_CONFIG
+	boolean
+	default y
+
+endif # OMAP_SSI
drivers/hsi/controllers/Makefile new file +5 -0
new file mode 100644
index 0000000..c4ba2c2
@@ -0,0 +1,5 @@
+#
+# Makefile for HSI controllers drivers
+#
+
+obj-$(CONFIG_OMAP_SSI)		+= omap_ssi.o
drivers/hsi/controllers/omap_ssi.c new file +1879 -0

1,879 lines not on this page · raw message

include/linux/platform_data/hsi-omap-ssi.h new file +202 -0

202 lines not on this page · raw message

Signature · 1 line
1.7.10.4
maintainer
#3 lore raw

Re: [PATCH 2/3] ARM: OMAP2+: HSI: Introduce OMAP SSI driver

Quoted 4 lines · Sebastian Reichel

From: Sebastian Reichel <[email protected]>

This patch adds an OMAP SSI driver to the HSI framework.

Quoted 8 lines

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.

Good to see this being worked on, maybe we can finally start making calls with mainline kernel :)

This one should be queued by:

$ scripts/get_maintainer.pl -f drivers/hsi

This should be a stand alone patch, right? You should resend with those people in cc.

Regards,

Tony

#4 lore raw

Re: [PATCH 2/3] ARM: OMAP2+: HSI: Introduce OMAP SSI driver

In reply to Sebastian Reichel
Quoted 4 lines · Sebastian Reichel

From: Sebastian Reichel <[email protected]>

This patch adds an OMAP SSI driver to the HSI framework.

Quoted 8 lines

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.

First: good to see this.

The HSI subsystem is lacking an active maintainer, interested? Given that you can apparently test the OMAP HSI driver you're one of the few applicable candidates.

Overall there is one big problem with this patch in that it implements a lot of stuff that should not be implemented in the driver at all, but in the HSI core.

For example compare commit
ffbbdd21329f3e15eeca6df2d4bc11c04d9d91c0
"spi: create a message queueing infrastructure"

This patch basically seems to redo the mistake we did in SPI and not create a central message queue from day one, instead re-implementing the same code in each and every driver.

Please attempt to draw the message queueuing into the driver core atlease.

Further the allocation of hosts seem pretty generic as well but I'm unsure about this. I'd prefer if you take a second look at the generalizeable parts.

(...)

drivers/hsi/controllers/omap_ssi.c line 125

Quoted 13 lines
Quoted 1 line

+ spinlock_t wk_lock;

drivers/hsi/controllers/omap_ssi.c new file +12 -0
+       spinlock_t              lock;
+       unsigned int            channels;
+       struct list_head        txqueue[SSI_MAX_CHANNELS];
+       struct list_head        rxqueue[SSI_MAX_CHANNELS];
+       struct list_head        brkqueue;
+       unsigned int            irq;
+       int                     wake_irq;
+       int                     wake_gpio;
+       struct tasklet_struct   pio_tasklet;
+       struct tasklet_struct   wake_tasklet;
+       unsigned int            wktest:1; /* FIXME: HACK to be removed */
+       unsigned int            wkin_cken:1; /* Workaround */

Atleast make them into the bool type.

Quoted 1 line

+ int wk_refcount;

A refcount does not seem like it coul be negative. Should this be unsigned?

Since these seem to be associated with a piece of code that only runs when this goes to 0, why not just use kref?

Quoted 24 lines
drivers/hsi/controllers/omap_ssi.c new file +24 -0
+       /* OMAP SSI port context */
+       u32                     sys_mpu_enable; /* We use only one irq */
+       struct omap_ssm_ctx     sst;
+       struct omap_ssm_ctx     ssr;
+};
+
+/**
+ * struct omap_ssi_controller - OMAP SSI controller data
+ * @dev: device associated to the controller (HSI controller)
+ * @sys: SSI I/O base address
+ * @gdd: GDD I/O base address
+ * @ick: SSI interconnect clock
+ * @fck: SSI functional clock
+ * @ck_refcount: References count for clocks
+ * @gdd_irq: IRQ line for GDD
+ * @gdd_tasklet: bottom half for DMA transfers
+ * @gdd_trn: Array of GDD transaction data for ongoing GDD transfers
+ * @lock: lock to serialize access to GDD
+ * @ck_lock: lock to serialize access to the clocks
+ * @loss_count: To follow if we need to restore context or not
+ * @max_speed: Maximum TX speed (Kb/s) set by the clients.
+ * @sysconfig: SSI controller saved context
+ * @gdd_gcr: SSI GDD saved context
+ * @get_loss: Pointer to omap_pm_get_dev_context_loss_count, if any

drivers/hsi/controllers/omap_ssi.c line 160

Quoted 10 lines
drivers/hsi/controllers/omap_ssi.c new file +10 -0
+ * @port: Array of pointers of the ports of the controller
+ * @dir: Debugfs SSI root directory
+ */
+struct omap_ssi_controller {
+       struct device           *dev;
+       void __iomem            *sys;
+       void __iomem            *gdd;
+       struct clk              *ick;
+       struct clk              *fck;
+       int                     ck_refcount;

Unsigned?

Since these seem to be associated with a piece of code that only runs when this goes to 0, why not just use kref?

(...)

drivers/hsi/controllers/omap_ssi.c line 208

Quoted 11 lines
drivers/hsi/controllers/omap_ssi.c new file +11 -0
+static int ssi_set_port_mode(struct omap_ssi_port *omap_port, void *data)
+{
+       u32 *mode = data;
+
+       __raw_writel(*mode, omap_port->sst_base + SSI_SST_MODE_REG);
+       __raw_writel(*mode, omap_port->ssr_base + SSI_SSR_MODE_REG);
+       /* OCP barrier */
+       *mode = __raw_readl(omap_port->ssr_base + SSI_SSR_MODE_REG);
+
+       return 0;
+}

Why do you insist on using __raw_readl/writel()? I can understand that you want to use readl/writel_relaxed() but __raw* is just ugly and confusing.

The last in a series of writel should probably be a plain writel() so as to flush buffers etc.

Comment applies to every instance of these.

Quoted 4 lines
drivers/hsi/controllers/omap_ssi.c new file +4 -0
+static u32 ssi_calculate_div(struct hsi_controller *ssi)
+{
+       struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi);
+       u32 tx_fckrate = (u32) omap_ssi->fck_rate;

drivers/hsi/controllers/omap_ssi.c line 768

Quoted 10 lines
drivers/hsi/controllers/omap_ssi.c new file +10 -0
+
+       /* / 2 : SSI TX clock is always half of the SSI functional clock */
+       tx_fckrate >>= 1;
+       /* Round down when tx_fckrate % omap_ssi->max_speed == 0 */
+       tx_fckrate--;
+       dev_dbg(&ssi->device, "TX div %d for fck_rate %lu Khz speed %d Kb/s\n",
+                       tx_fckrate / omap_ssi->max_speed, omap_ssi->fck_rate,
+                                                       omap_ssi->max_speed);
+
+       return tx_fckrate / omap_ssi->max_speed;

Don't you want to use:
DIV_ROUND_CLOSEST(tx_fckrate, omap_ssi->max_speed) ?

(...)

Quoted 2 lines
drivers/hsi/controllers/omap_ssi.c new file +2 -0
+static int ssi_setup(struct hsi_client *cl)
+{

(...)

drivers/hsi/controllers/omap_ssi.c line 1007

Quoted 7 lines
drivers/hsi/controllers/omap_ssi.c new file +7 -0
+       /* Set TX/RX module to sleep to stop TX/RX during cfg update */
+       __raw_writel(SSI_MODE_SLEEP, sst + SSI_SST_MODE_REG);
+       __raw_writel(SSI_MODE_SLEEP, ssr + SSI_SSR_MODE_REG);
+       /* Flush posted write */
+       val = __raw_readl(ssr + SSI_SSR_MODE_REG);
+       /* TX */
+       __raw_writel(31, sst + SSI_SST_FRAMESIZE_REG);

31??

Use a #define for this, I have no clue why this is 31.

(...)

Quoted 1 line

+ __raw_writel(31, ssr + SSI_SSR_FRAMESIZE_REG);

(...)

Quoted 1 line

+ omap_port->sst.frame_size = 31;

(...)

Quoted 1 line

+ omap_port->ssr.frame_size = 31;

Seems like some universal constant.

Quoted 1 line

+static int ssi_flush(struct hsi_client *cl)

(...)

drivers/hsi/controllers/omap_ssi.c line 1206

Quoted 6 lines
drivers/hsi/controllers/omap_ssi.c new file +6 -0
+       /* Clear interrupts */
+       __raw_writel(0, omap_ssi->sys + SSI_MPU_ENABLE_REG(port->num, 0));
+       __raw_writel(0xffffff00,
+                       omap_ssi->sys + SSI_MPU_STATUS_REG(port->num, 0));
+       __raw_writel(0, omap_ssi->sys + SSI_GDD_MPU_IRQ_ENABLE_REG);
+       __raw_writel(0xff, omap_ssi->sys + SSI_GDD_MPU_IRQ_STATUS_REG);

Here are other magic numbers 0xfffff00, 0xff...

(...)

Quoted 9 lines
drivers/hsi/controllers/omap_ssi.c new file +9 -0
+static int __init ssi_hw_init(struct hsi_controller *ssi)
+{
+       struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi);
+       unsigned int i;
+       u32 val;
+       int err;
+
+       err = ssi_clk_enable(ssi);
+       if (err < 0) {

drivers/hsi/controllers/omap_ssi.c line 1781

Quoted 10 lines
drivers/hsi/controllers/omap_ssi.c new file +10 -0
+               dev_err(&ssi->device, "Failed to enable the clocks %d\n", err);
+               return err;
+       }
+       /* Reseting SSI controller */
+       __raw_writel(SSI_SOFTRESET, omap_ssi->sys + SSI_SYSCONFIG_REG);
+       val = __raw_readl(omap_ssi->sys + SSI_SYSSTATUS_REG);
+       for (i = 0; ((i < 20) && !(val & SSI_RESETDONE)); i++) {
+               msleep(20);
+               val = __raw_readl(omap_ssi->sys + SSI_SYSSTATUS_REG);
+       }

Explain constants chosen in a comment. From datasheet?

drivers/hsi/controllers/omap_ssi.c line 1790

Quoted 4 lines
drivers/hsi/controllers/omap_ssi.c new file +4 -0
+       /* Reseting GDD */
+       __raw_writel(SSI_SWRESET, omap_ssi->gdd + SSI_GDD_GRST_REG);
+       /* Get FCK rate */
+       omap_ssi->fck_rate = ssi_get_clk_rate(ssi) / 1000; /* KHz */

DIV_ROUND_CLOSEST()? Or is this an integer divider?

Yours,
Linus Walleij

#5 lore raw

Re: [PATCH 2/3] ARM: OMAP2+: HSI: Introduce OMAP SSI driver

Hi,

Quoted 3 lines · Linus Walleij

The HSI subsystem is lacking an active maintainer, interested? Given that you can apparently test the OMAP HSI driver you're one of the few applicable candidates.

I don't think I'm a good candidate for that. At least not yet. This is my first patch sent to the kernel and I merly took the code from Carlos Chinea and ported it to some new kernel frameworks. Apart from that I'm lacking any documentation for the interface (SSI is not part of TI's public OMAP3 TRM).

Quoted 3 lines

Overall there is one big problem with this patch in that it implements a lot of stuff that should not be implemented in the driver at all, but in the HSI core.

The actual implementation has not (yet?) been changed by me. It's still the code as written by Carlos.

Quoted 11 lines

For example compare commit
ffbbdd21329f3e15eeca6df2d4bc11c04d9d91c0
"spi: create a message queueing infrastructure"

This patch basically seems to redo the mistake we did in SPI and not create a central message queue from day one, instead re-implementing the same code in each and every driver.

Please attempt to draw the message queueuing into the driver core atlease.

I will have a look at it after conversion to DT. I will sent another RFC before this change to speed up the DT review, though.

Quoted 3 lines

Further the allocation of hosts seem pretty generic as well but I'm unsure about this. I'd prefer if you take a second look at the generalizeable parts.

OK.

Quoted 1 line

[...] (Code Comments)

Thanks for the review. The code has been written by Carlos, who apparently had documentation for the SSI IP used in the OMAP3. I cannot fix the magic numbers without either reverse engineering the IP (which I do not have the time for) or access to the documentation.

I will fix the other comments in the next RFC patch.

-- Sebastian

#6 lore raw

PATCH 3/3 ARM: OMAP2+: Add SSI driver configuration

In reply to Sebastian Reichel

From: Sebastian Reichel <[email protected]>

This patch configures and activates the OMAP SSI driver on the RX-51.

---
 arch/arm/mach-omap2/Makefile                 |    4 ++
 arch/arm/mach-omap2/board-rx51-peripherals.c |   10 +++-
 arch/arm/mach-omap2/ssi.c                    |   82 ++++++++++++++++++++++++++
 3 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-omap2/ssi.c
arch/arm/mach-omap2/Makefile +4 -0
index d4f6715..ace860d 100644
@@ -222,6 +222,10 @@ ifneq ($(CONFIG_DRM_OMAP),)
 obj-y					+= drm.o
 endif
 
+# Synchronous Serial Interface (SSI)
+omap-ssi-$(CONFIG_OMAP_SSI)		:= ssi.o
+obj-y					+= $(omap-ssi-m) $(omap-ssi-y)
+
 # Specific board support
 obj-$(CONFIG_MACH_OMAP_GENERIC)		+= board-generic.o
 obj-$(CONFIG_MACH_OMAP_H4)		+= board-h4.o
arch/arm/mach-omap2/board-rx51-peripherals.c +9 -1
index 9c2dd10..e2ca155 100644
@@ -27,6 +27,7 @@
 #include <linux/power/isp1704_charger.h>
 #include <linux/platform_data/spi-omap2-mcspi.h>
 #include <linux/platform_data/mtd-onenand-omap2.h>
+#include <linux/platform_data/hsi-omap-ssi.h>
 
 #include <asm/system_info.h>
 
@@ -73,6 +74,8 @@
 #define LIS302_IRQ1_GPIO 181
 #define LIS302_IRQ2_GPIO 180  /* Not yet in use */
 
+#define RX51_CAWAKE_GPIO 151
+
 /* List all SPI devices here. Note that the list/probe order seems to matter! */
 enum {
 	RX51_SPI_WL1251,
@@ -265,6 +268,11 @@ static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
 	},
 };
 
+static struct omap_ssi_board_config ssi_board_config = {
+	.num_ports = 1,
+	.cawake_gpio = { RX51_CAWAKE_GPIO },
+};
+
 static struct platform_device rx51_battery_device = {
 	.name	= "rx51-battery",
 	.id	= -1,
@@ -1295,7 +1303,7 @@ void __init rx51_peripherals_init(void)
 	if (partition)
 		omap_hsmmc_init(mmc);
 
+	omap_ssi_config(&ssi_board_config);
 	rx51_charger_init();
 	rx51_init_twl4030_hwmon();
 }
-
arch/arm/mach-omap2/ssi.c new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
1.7.10.4
maintainer
#7 lore raw

Re: [PATCH 3/3] ARM: OMAP2+: Add SSI driver configuration

Quoted 3 lines · Sebastian Reichel

From: Sebastian Reichel <[email protected]>

This patch configures and activates the OMAP SSI driver on the RX-51.

Hmm, I'd rather see this be DT only driver at this point. We're pretty close to flipping omap3 to be DT only, and I'd rather not add new platform code at this point. With DT, none of this patch is needed, you can do all this in the driver probe based on the .dts configuration.

Regards,

Tony

Quoted 158 lines
 arch/arm/mach-omap2/Makefile                 |    4 ++
 arch/arm/mach-omap2/board-rx51-peripherals.c |   10 +++-
 arch/arm/mach-omap2/ssi.c                    |   82 ++++++++++++++++++++++++++
 3 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-omap2/ssi.c
arch/arm/mach-omap2/Makefile +4 -0
index d4f6715..ace860d 100644
@@ -222,6 +222,10 @@ ifneq ($(CONFIG_DRM_OMAP),)
 obj-y					+= drm.o
 endif
 
+# Synchronous Serial Interface (SSI)
+omap-ssi-$(CONFIG_OMAP_SSI)		:= ssi.o
+obj-y					+= $(omap-ssi-m) $(omap-ssi-y)
+
 # Specific board support
 obj-$(CONFIG_MACH_OMAP_GENERIC)		+= board-generic.o
 obj-$(CONFIG_MACH_OMAP_H4)		+= board-h4.o
arch/arm/mach-omap2/board-rx51-peripherals.c +9 -1
index 9c2dd10..e2ca155 100644
@@ -27,6 +27,7 @@
 #include <linux/power/isp1704_charger.h>
 #include <linux/platform_data/spi-omap2-mcspi.h>
 #include <linux/platform_data/mtd-onenand-omap2.h>
+#include <linux/platform_data/hsi-omap-ssi.h>
 
 #include <asm/system_info.h>
 
@@ -73,6 +74,8 @@
 #define LIS302_IRQ1_GPIO 181
 #define LIS302_IRQ2_GPIO 180  /* Not yet in use */
 
+#define RX51_CAWAKE_GPIO 151
+
 /* List all SPI devices here. Note that the list/probe order seems to matter! */
 enum {
 	RX51_SPI_WL1251,
@@ -265,6 +268,11 @@ static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
 	},
 };
 
+static struct omap_ssi_board_config ssi_board_config = {
+	.num_ports = 1,
+	.cawake_gpio = { RX51_CAWAKE_GPIO },
+};
+
 static struct platform_device rx51_battery_device = {
 	.name	= "rx51-battery",
 	.id	= -1,
@@ -1295,7 +1303,7 @@ void __init rx51_peripherals_init(void)
 	if (partition)
 		omap_hsmmc_init(mmc);
 
+	omap_ssi_config(&ssi_board_config);
 	rx51_charger_init();
 	rx51_init_twl4030_hwmon();
 }
-
arch/arm/mach-omap2/ssi.c new file +82 -0
new file mode 100644
index 0000000..a9d6eee
@@ -0,0 +1,82 @@
+/*
+ * linux/arch/arm/mach-omap2/ssi.c
+ *
+ * Copyright (C) 2010 Nokia Corporation. All rights reserved.
+ *
+ * Contact: Carlos Chinea <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/platform_data/hsi-omap-ssi.h>
+#include "omap_hwmod.h"
+#include "omap_device.h"
+#include "omap-pm.h"
+
+static struct omap_ssi_platform_data ssi_pdata = {
+	.num_ports      = SSI_NUM_PORTS,
+	.cawake_gpio    = {0},
+	.get_dev_context_loss_count  = omap_pm_get_dev_context_loss_count,
+};
+
+int __init omap_ssi_config(struct omap_ssi_board_config *ssi_config)
+{
+	unsigned int port, offset, cawake_gpio;
+	int err;
+
+	ssi_pdata.num_ports = ssi_config->num_ports;
+
+	for (port = 0, offset = 7; port < ssi_config->num_ports; port++, offset += 5) {
+		cawake_gpio = ssi_config->cawake_gpio[port];
+		if (!cawake_gpio)
+			continue; /* Nothing to do */
+		err = gpio_request(cawake_gpio, "cawake");
+		if (err < 0)
+			goto rback;
+		gpio_direction_input(cawake_gpio);
+
+		ssi_pdata.cawake_gpio[port] = ssi_config->cawake_gpio[port];
+	}
+
+	return 0;
+
+rback:
+	pr_err("omap-ssi: Request cawake (gpio%d) failed\n", cawake_gpio);
+	while (port > 0)
+		gpio_free(ssi_config->cawake_gpio[--port]);
+
+	return err;
+}
+
+static int __init omap_ssi_init(void)
+{
+	struct omap_hwmod *oh;
+	struct platform_device *pdev;
+
+	oh = omap_hwmod_lookup("ssi");
+	if (!oh)
+		return -EINVAL;
+
+	pdev = omap_device_build("omap_ssi", 0, oh, &ssi_pdata, sizeof(struct omap_ssi_platform_data));
+	WARN(IS_ERR(pdev), "Can't build omap_device for omap_ssi\n");
+
+	return 0;
+}
+subsys_initcall(omap_ssi_init);
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

Re: [PATCH 3/3] ARM: OMAP2+: Add SSI driver configuration

Quoted 6 lines · Tony Lindgren
Quoted 3 lines · Sebastian Reichel

From: Sebastian Reichel <[email protected]>

This patch configures and activates the OMAP SSI driver on the RX-51.

Hmm, I'd rather see this be DT only driver at this point.

+1 on this.

Yours,
Linus Walleij

#9 lore raw

Re: [PATCH 3/3] ARM: OMAP2+: Add SSI driver configuration

Quoted 9 lines · Linus Walleij
Quoted 6 lines · Tony Lindgren
Quoted 3 lines · Sebastian Reichel

From: Sebastian Reichel <[email protected]>

This patch configures and activates the OMAP SSI driver on the RX-51.

Hmm, I'd rather see this be DT only driver at this point.

+1 on this.

I'm already working on this.

-- Sebastian

maintainer
#10 lore raw

Re: [PATCH 3/3] ARM: OMAP2+: Add SSI driver configuration

Quoted 5 lines · Sebastian Reichel
Quoted 4 lines · Linus Walleij
Quoted 3 lines · Tony Lindgren
Quoted 2 lines · Sebastian Reichel

From: Sebastian Reichel <[email protected]>

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

This patch configures and activates the OMAP SSI driver on the RX-51.

Hmm, I'd rather see this be DT only driver at this point.

+1 on this.

I'm already working on this.

Thanks good to hear!

Tony

maintainer
#11 lore raw

Re: [PATCH 1/3] ARM: OMAP2+: hwmod-data: Add SSI information

In reply to Sebastian Reichel
Quoted 4 lines · Sebastian Reichel

From: Sebastian Reichel <[email protected]>

This patch adds Synchronous Serial Interface (SSI) hwmod support for OMAP34xx SoCs.

This should be queued or acked by Paul.

Regards,

Tony

Quoted 132 lines
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |  104 ++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +104 -0
index 0c3a427..74006c4 100644
@@ -3693,6 +3693,109 @@ static struct omap_hwmod_ocp_if omap3xxx_l4_core__aes = {
 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
 };
 
+/*
+ * 'ssi' class
+ * synchronous serial interface (multichannel and full-duplex serial if)
+ */
+
+static struct omap_hwmod_class_sysconfig omap34xx_ssi_sysc = {
+	.rev_offs	= 0x0000,
+	.sysc_offs	= 0x0010,
+	.syss_offs	= 0x0014,
+	.sysc_flags	= (SYSC_HAS_AUTOIDLE | SYSC_HAS_EMUFREE |
+			   SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE |
+			   SYSC_HAS_SOFTRESET | SYSS_HAS_RESET_STATUS),
+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+			   SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO |
+			   MSTANDBY_SMART | MSTANDBY_SMART_WKUP),
+	.sysc_fields	= &omap_hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class omap34xx_ssi_hwmod_class = {
+	.name	= "ssi",
+	.sysc	= &omap34xx_ssi_sysc,
+};
+
+static struct omap_hwmod_irq_info omap34xx_ssi_irqs[] = {
+	{ .name = "ssi_p1_mpu_irq0", .irq = 67 },
+	{ .name = "ssi_p1_mpu_irq1", .irq = 68 },
+	{ .name = "ssi_p2_mpu_irq0", .irq = 69 },
+	{ .name = "ssi_p2_mpu_irq1", .irq = 70 },
+	{ .name = "ssi_gdd_mpu",     .irq = 71 },
+	{ .irq = -1 },
+};
+
+static struct omap_hwmod_addr_space omap34xx_ssi_addrs[] = {
+	{
+		.name		= "sys",
+		.pa_start	= 0x48058000,
+		.pa_end		= 0x48058fff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* generic distributed DMA */
+		.name		= "gdd",
+		.pa_start	= 0x48059000,
+		.pa_end		= 0x48059fff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 1: synchronous serial transmitter */
+		.name		= "p1_sst",
+		.pa_start	= 0x4805a000,
+		.pa_end		= 0x4805a7ff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 1: synchronous serial receiver */
+		.name		= "p1_ssr",
+		.pa_start	= 0x4805a800,
+		.pa_end		= 0x4805afff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 2: synchronous serial transmitter */
+		.name		= "p2_sst",
+		.pa_start	= 0x4805b000,
+		.pa_end		= 0x4805b7ff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 2: synchronous serial receiver */
+		.name		= "p2_ssr",
+		.pa_start	= 0x4805b800,
+		.pa_end		= 0x4805bfff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{}
+};
+
+static struct omap_hwmod omap34xx_ssi_hwmod = {
+	.name		= "ssi",
+	.class		= &omap34xx_ssi_hwmod_class,
+	.clkdm_name	= "l3_init_clkdm",
+	.mpu_irqs	= omap34xx_ssi_irqs,
+	.main_clk	= "ssi_ssr_fck",
+	.prcm		= {
+		.omap2 = {
+			.prcm_reg_id		= 1,
+			.module_bit		= OMAP3430_EN_SSI_SHIFT,
+			.module_offs		= WKUP_MOD,
+			.idlest_reg_id		= 1,
+			.idlest_idle_bit	= OMAP3430ES2_ST_SSI_IDLE_SHIFT,
+		},
+	},
+};
+
+/* SSI -> l3 */
+static struct omap_hwmod_ocp_if omap34xx_l3__ssi = {
+	.master		= &omap3xxx_l3_main_hwmod,
+	.slave		= &omap34xx_ssi_hwmod,
+	.clk		= "ssi_ick",
+	.addr		= omap34xx_ssi_addrs,
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
+
 static struct omap_hwmod_ocp_if *omap3xxx_hwmod_ocp_ifs[] __initdata = {
 	&omap3xxx_l3_main__l4_core,
 	&omap3xxx_l3_main__l4_per,
@@ -3818,6 +3921,7 @@ static struct omap_hwmod_ocp_if *omap34xx_hwmod_ocp_ifs[] __initdata = {
 #ifdef CONFIG_OMAP_IOMMU_IVA2
 	&omap3xxx_l3_main__mmu_iva,
 #endif
+	&omap34xx_l3__ssi,
 	NULL
 };
 
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#12 lore raw

Re: [PATCH 1/3] ARM: OMAP2+: hwmod-data: Add SSI information

In reply to Sebastian Reichel

Hi Sebastian

Quoted 4 lines · Sebastian Reichel

From: Sebastian Reichel <[email protected]>

This patch adds Synchronous Serial Interface (SSI) hwmod support for OMAP34xx SoCs.

a few comments:

- please add your Signed-off-by: to the patch description, per Documentation/SubmittingPatches

- please drop "omap34xx_ssi_irqs" and "omap34xx_ssi_addrs" - that data should go into DT now

The rest looks OK to me, based on a brief look.

...

FYI, this is stretching my recollection, and is not directly related to this patch, but I seem to recall that there was a problem with auto-idle when SSI was active on the 3430. Basically, if the SSI was active, but other CORE_L3/CORE_L4 clockdomain devices weren't, I think that DPLL3 would be incorrectly shut down. You'll probably need to check the Nokia kernel source for details. I thought we had a hwmod flag for this, but I guess not. Anyway, in case you notice odd behavior...

- Paul

Quoted 134 lines
---
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |  104 ++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +104 -0
index 0c3a427..74006c4 100644
@@ -3693,6 +3693,109 @@ static struct omap_hwmod_ocp_if omap3xxx_l4_core__aes = {
 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
 };
 
+/*
+ * 'ssi' class
+ * synchronous serial interface (multichannel and full-duplex serial if)
+ */
+
+static struct omap_hwmod_class_sysconfig omap34xx_ssi_sysc = {
+	.rev_offs	= 0x0000,
+	.sysc_offs	= 0x0010,
+	.syss_offs	= 0x0014,
+	.sysc_flags	= (SYSC_HAS_AUTOIDLE | SYSC_HAS_EMUFREE |
+			   SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE |
+			   SYSC_HAS_SOFTRESET | SYSS_HAS_RESET_STATUS),
+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+			   SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO |
+			   MSTANDBY_SMART | MSTANDBY_SMART_WKUP),
+	.sysc_fields	= &omap_hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class omap34xx_ssi_hwmod_class = {
+	.name	= "ssi",
+	.sysc	= &omap34xx_ssi_sysc,
+};
+
+static struct omap_hwmod_irq_info omap34xx_ssi_irqs[] = {
+	{ .name = "ssi_p1_mpu_irq0", .irq = 67 },
+	{ .name = "ssi_p1_mpu_irq1", .irq = 68 },
+	{ .name = "ssi_p2_mpu_irq0", .irq = 69 },
+	{ .name = "ssi_p2_mpu_irq1", .irq = 70 },
+	{ .name = "ssi_gdd_mpu",     .irq = 71 },
+	{ .irq = -1 },
+};
+
+static struct omap_hwmod_addr_space omap34xx_ssi_addrs[] = {
+	{
+		.name		= "sys",
+		.pa_start	= 0x48058000,
+		.pa_end		= 0x48058fff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* generic distributed DMA */
+		.name		= "gdd",
+		.pa_start	= 0x48059000,
+		.pa_end		= 0x48059fff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 1: synchronous serial transmitter */
+		.name		= "p1_sst",
+		.pa_start	= 0x4805a000,
+		.pa_end		= 0x4805a7ff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 1: synchronous serial receiver */
+		.name		= "p1_ssr",
+		.pa_start	= 0x4805a800,
+		.pa_end		= 0x4805afff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 2: synchronous serial transmitter */
+		.name		= "p2_sst",
+		.pa_start	= 0x4805b000,
+		.pa_end		= 0x4805b7ff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{
+		/* port 2: synchronous serial receiver */
+		.name		= "p2_ssr",
+		.pa_start	= 0x4805b800,
+		.pa_end		= 0x4805bfff,
+		.flags		= ADDR_TYPE_RT,
+	},
+	{}
+};
+
+static struct omap_hwmod omap34xx_ssi_hwmod = {
+	.name		= "ssi",
+	.class		= &omap34xx_ssi_hwmod_class,
+	.clkdm_name	= "l3_init_clkdm",
+	.mpu_irqs	= omap34xx_ssi_irqs,
+	.main_clk	= "ssi_ssr_fck",
+	.prcm		= {
+		.omap2 = {
+			.prcm_reg_id		= 1,
+			.module_bit		= OMAP3430_EN_SSI_SHIFT,
+			.module_offs		= WKUP_MOD,
+			.idlest_reg_id		= 1,
+			.idlest_idle_bit	= OMAP3430ES2_ST_SSI_IDLE_SHIFT,
+		},
+	},
+};
+
+/* SSI -> l3 */
+static struct omap_hwmod_ocp_if omap34xx_l3__ssi = {
+	.master		= &omap3xxx_l3_main_hwmod,
+	.slave		= &omap34xx_ssi_hwmod,
+	.clk		= "ssi_ick",
+	.addr		= omap34xx_ssi_addrs,
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
+
 static struct omap_hwmod_ocp_if *omap3xxx_hwmod_ocp_ifs[] __initdata = {
 	&omap3xxx_l3_main__l4_core,
 	&omap3xxx_l3_main__l4_per,
@@ -3818,6 +3921,7 @@ static struct omap_hwmod_ocp_if *omap34xx_hwmod_ocp_ifs[] __initdata = {
 #ifdef CONFIG_OMAP_IOMMU_IVA2
 	&omap3xxx_l3_main__mmu_iva,
 #endif
+	&omap34xx_l3__ssi,
 	NULL
 };
 
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

- Paul

#13 lore raw

Re: [PATCH 1/3] ARM: OMAP2+: hwmod-data: Add SSI information

Hi Paul,

Quoted 8 lines · Paul Walmsley
Quoted 3 lines

From: Sebastian Reichel <[email protected]>
This patch adds Synchronous Serial Interface (SSI) hwmod support for OMAP34xx SoCs.

a few comments:

- please add your Signed-off-by: to the patch description, per Documentation/SubmittingPatches

I assumed this was only important, when I actually want to submit patches. This was merely a first RFC. I will do this for the next round of patches.

Quoted 2 lines

- please drop "omap34xx_ssi_irqs" and "omap34xx_ssi_addrs" - that data should go into DT now

I'm currently working on converting the driver to use DT. I will send another patch when I'm done.

Quoted 8 lines

[...]
FYI, this is stretching my recollection, and is not directly related to this patch, but I seem to recall that there was a problem with auto-idle when SSI was active on the 3430. Basically, if the SSI was active, but other CORE_L3/CORE_L4 clockdomain devices weren't, I think that DPLL3 would be incorrectly shut down. You'll probably need to check the Nokia kernel source for details. I thought we had a hwmod flag for this, but I guess not. Anyway, in case you notice odd behavior...

OK. Thanks for the hint.

-- Sebastian

maintainer
#14 lore raw

Re: [PATCH 1/3] ARM: OMAP2+: hwmod-data: Add SSI information

Hi

Quoted 5 lines · Sebastian Reichel
Quoted 4 lines · Paul Walmsley
Quoted 3 lines

From: Sebastian Reichel <[email protected]>
This patch adds Synchronous Serial Interface (SSI) hwmod support for OMAP34xx SoCs.

Quoted 8 lines
Quoted 4 lines

a few comments:

- please add your Signed-off-by: to the patch description, per Documentation/SubmittingPatches

I assumed this was only important, when I actually want to submit patches. This was merely a first RFC. I will do this for the next round of patches.

OK makes sense. Just FYI, usually when folks send out RFCs, they put "RFC" in the patch description for each patch. So the subject line might read:

[RFC PATCH 1/3] ARM: OMAP2+: hwmod-data: Add SSI information

Quoted 5 lines
Quoted 2 lines

- please drop "omap34xx_ssi_irqs" and "omap34xx_ssi_addrs" - that data should go into DT now

I'm currently working on converting the driver to use DT. I will send another patch when I'm done.

OK great.

- Paul