Skip to contentSkip to conversation

ARM: support for ICP DAS LP-8x4x

PATCH Superseded Sergei Ianovich 27 participants 304 messages Dec 1, 2013 – Sep 27, 2016 1 message not in the archive Page 3 of 3

Subsystems (15)
lore
Share & tools
lore
#271 lore raw

PATCH v5 2/2 arm: pxa27x: support for ICP DAS LP-8x4x w/ DT

In reply to Sergei Ianovich

ICP DAS calls LP-8x4x 'programmable automation controller'. It is an industrial computer based on PXA270 SoC. They ship it with a 2.6.19 kernel and proprietary kernel module and userspace library to access its industrial IO.

This patch allows to boot a modern kernel with device tree on the device. It adds support for:
* MMC card interface on PXA270
* USB 1.1 port on PXA270
* 2 NOR flash devices
* 2 onboard ethernet Davicom DM9000 devices
* 3 serial UART ports on PXA270
* front panel red LED
* 64bit 1-wire system ID chip
* 16 kiB EEPROM (reading)

Support for these devices will be added in separate patches, since they are not currently supported by the kernel:
* DS1302 RTC
* 512kiB SRAM
* FPGA irq chip
* 3 built-in 16550A serial UART ports
* industrial IO parallel bus
* 10 position rotary switch
* 8 pin DIP switch
* 16 kiB EEPROM (writing)
* serial interface for digital and analog industrial IO modules on parallel bus (all I-87xxx modules)
* digital and analog industrial IO modules for parallel bus:
** I-8024 4 port analog output
** I-8041 32 port digital output
** I-8042 16 port digital output/16 port digital input

Not supported for now:
* VGA interface on PXA270 for lack of dts binding
* the rest of parallel bus (I-8xxx) modules for lack of hardware
* GPIO reset for lack of relevance (watchdog reset is working)

Newer LP-8x4x devices have twice as much flash and a different partition structure otherwise being the same. When each device is provided with a correct device tree, all of them can be booted using the same kernel.

---
v4..v5
fixes to apply Rob Herring's "Acked-by":
* provide board compatible string
* remove unused include directive in pxa27x-lp8x4x.dts

v3..v4
* support for newer flavor w/ 96Mb flash memory
* use 'partitions' subnodes
* move device-specific tweaking to device .dts file and drop patches to pxa27x.dtsi

v2..v3
* added extbus which maps synchronous, static, and variable-latency I/O (VLIO) interfaces of PXA27x SoC as suggested by Arnd Bergmann
* map is placed into platform include
* configured existing kernel drivers to support:
- front panel LED using gpio-leds
- 64bit 1-wire system ID chip using w1-gpio
- 16 kiB EEPROM using at24 over i2c-gpio
* number change (06/16 -> 08/21)

v1..v2
* drop left-over extern declaration
* use of_have_populated_dt() instead of a static variable
* drop wildcards in compatible
* drop machine-special machine description
* number changed from 9 to 6 (dropped patches)

 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 arch/arm/boot/dts/Makefile                         |   3 +
 arch/arm/boot/dts/pxa27x-lp8x4x-i105.dts           |  50 ++++
 arch/arm/boot/dts/pxa27x-lp8x4x.dts                | 259 +++++++++++++++++++++
 arch/arm/configs/lp8x4x_defconfig                  | 176 ++++++++++++++
 5 files changed, 489 insertions(+)
 create mode 100644 arch/arm/boot/dts/pxa27x-lp8x4x-i105.dts
 create mode 100644 arch/arm/boot/dts/pxa27x-lp8x4x.dts
 create mode 100644 arch/arm/configs/lp8x4x_defconfig
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index 55df1d4..2f1b078 100644
@@ -109,6 +109,7 @@ honeywell	Honeywell
 hp	Hewlett Packard
 i2se	I2SE GmbH
 ibm	International Business Machines (IBM)
+icpdas	ICP DAS CO., LTD.
 idt	Integrated Device Technologies, Inc.
 iom	Iomega Corporation
 img	Imagination Technologies Ltd.
arch/arm/boot/dts/Makefile +3 -0
index 30bbc37..ed182ea 100644
@@ -499,6 +499,9 @@ dtb-$(CONFIG_ARCH_ORION5X) += \
 	orion5x-rd88f5182-nas.dtb
 dtb-$(CONFIG_ARCH_PRIMA2) += \
 	prima2-evb.dtb
+dtb-$(CONFIG_MACH_PXA27X_DT) += \
+	pxa27x-lp8x4x.dtb \
+	pxa27x-lp8x4x-i105.dtb
 dtb-$(CONFIG_ARCH_QCOM) += \
 	qcom-apq8064-cm-qs600.dtb \
 	qcom-apq8064-ifc6410.dtb \
arch/arm/boot/dts/pxa27x-lp8x4x-i105.dts new file +50 -0

50 lines not on this page · raw message

arch/arm/boot/dts/pxa27x-lp8x4x.dts new file +259 -0

259 lines not on this page · raw message

arch/arm/configs/lp8x4x_defconfig new file +176 -0

176 lines not on this page · raw message

Signature · 1 line
2.6.2
maintainer
#272 lore raw

Re: [PATCH v5 2/2] arm: pxa27x: support for ICP DAS LP-8x4x w/ DT

Quoted 6 lines · On Tuesday 15 December 2015 19:27:50 Sergei Ianovich wrote:
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 arch/arm/boot/dts/Makefile                         |   3 +
 arch/arm/boot/dts/pxa27x-lp8x4x-i105.dts           |  50 ++++
 arch/arm/boot/dts/pxa27x-lp8x4x.dts                | 259 +++++++++++++++++++++
 arch/arm/configs/lp8x4x_defconfig                  | 176 ++++++++++++++

I had not noticed earlier that you are adding a new defconfig file. PXA is already the platform with the most defconfig files, and I'd rather like to see that reduced than increased.

Is there a chance you could merge this one with some of the existing files into one configuration that handles them all?

Arnd

#273 lore raw

Re: [PATCH v5 2/2] arm: pxa27x: support for ICP DAS LP-8x4x w/ DT

Quoted 16 lines · Arnd Bergmann
Quoted 8 lines · On Tuesday 15 December 2015 19:27:50 Sergei Ianovich wrote:
?.../devicetree/bindings/vendor-prefixes.txt????????|???1 +
?arch/arm/boot/dts/Makefile?????????????????????????|???3 +
?arch/arm/boot/dts/pxa27x-lp8x4x-i105.dts???????????|??50 ++++
?arch/arm/boot/dts/pxa27x-lp8x4x.dts????????????????| 259

+++++++++++++++++++++
?arch/arm/configs/lp8x4x_defconfig??????????????????| 176
++++++++++++++

I had not noticed earlier that you are adding a new defconfig file. PXA is
already the platform with the most defconfig files, and I'd rather like
to see that reduced than increased.

Quoted 3 lines

Is there a chance you could merge this one with some of the existing files
into one configuration that handles them all?

There are several board-specific devices on LP8x4x: custom FPGA, custom UART, custom IRQ on FPGA, custom parallel bus for industrial IO. The defconfig file could alert potential users to this fact. If this is not a sufficient reason to have a defconfig file, it can be dropped.

I use the full .config anyway :)

maintainer
#274 lore raw

Re: [PATCH v5 2/2] arm: pxa27x: support for ICP DAS LP-8x4x w/ DT

Quoted 21 lines · On Tuesday 15 December 2015 19:42:07 Sergei Ianovich wrote:
Quoted 16 lines · Arnd Bergmann
Quoted 8 lines · On Tuesday 15 December 2015 19:27:50 Sergei Ianovich wrote:
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 arch/arm/boot/dts/Makefile                         |   3 +
 arch/arm/boot/dts/pxa27x-lp8x4x-i105.dts           |  50 ++++
 arch/arm/boot/dts/pxa27x-lp8x4x.dts                | 259
+++++++++++++++++++++
 arch/arm/configs/lp8x4x_defconfig                  | 176

++++++++++++++

I had not noticed earlier that you are adding a new defconfig file. PXA is
already the platform with the most defconfig files, and I'd rather like
to see that reduced than increased.

Quoted 3 lines

Is there a chance you could merge this one with some of the existing files
into one configuration that handles them all?

Quoted 6 lines

There are several board-specific devices on LP8x4x: custom FPGA, custom UART, custom IRQ on FPGA, custom parallel bus for industrial IO. The defconfig file could alert potential users to this fact. If this is not a sufficient reason to have a defconfig file, it can be dropped.

I use the full .config anyway

I would like those drivers to be enabled in some defconfig, so we get compile-time coverage, but we generally stopped having one-config-per-board files.

Maybe we can have a pxa_defconfig file that enables lots of boards and then we remove the individual configs? We don't have to remove them all at once, but it would make me very happy if we could at least kill off some of the ones that are not used regularly.

Arnd

#275 lore raw

Re: [PATCH v5 2/2] arm: pxa27x: support for ICP DAS LP-8x4x w/ DT

Quoted 15 lines · Arnd Bergmann
Quoted 8 lines · On Tuesday 15 December 2015 19:42:07 Sergei Ianovich wrote:

There are several board-specific devices on LP8x4x: custom FPGA, custom
UART, custom IRQ on FPGA, custom parallel bus for industrial IO. The defconfig file could alert potential users to this fact. If this is not
a sufficient reason to have a defconfig file, it can be dropped.

I use the full .config anyway

I would like those drivers to be enabled in some defconfig, so we get compile-time coverage, but we generally stopped having one-config-per- board
files.

Quoted 4 lines

Maybe we can have a pxa_defconfig file that enables lots of boards and then we remove the individual configs? We don't have to remove them all at once, but it would make me very happy if we could at least kill off some of the ones that are not used regularly.

lp8x4x seems to be the first pxa board which requires DT.

We can create pxa27x-dt_defconfig which selects:
1. PXA27X_DT
2. PXA_FB and 8250_PXA to enable console
3. MMC, MMC_PXA and EXT4_FS to enable boot from MMC
4. all optional pxa stuff as modules
5. all stuff on supported pxa boards as modules

If #5 is extended when support for new boards is added, it should be possible to run any supported pxa27x board with pxa27x_defconfig.

maintainer
#276 lore raw

Re: [PATCH v5 2/2] arm: pxa27x: support for ICP DAS LP-8x4x w/ DT

Quoted 16 lines · Sergei Ianovich
Quoted 15 lines · Arnd Bergmann
Quoted 8 lines · On Tuesday 15 December 2015 19:42:07 Sergei Ianovich wrote:

There are several board-specific devices on LP8x4x: custom FPGA, custom
UART, custom IRQ on FPGA, custom parallel bus for industrial IO. The defconfig file could alert potential users to this fact. If this is not
a sufficient reason to have a defconfig file, it can be dropped.

I use the full .config anyway

I would like those drivers to be enabled in some defconfig, so we get compile-time coverage, but we generally stopped having one-config-per- board
files.

Quoted 4 lines
Quoted 4 lines

Maybe we can have a pxa_defconfig file that enables lots of boards and then we remove the individual configs? We don't have to remove them all at once, but it would make me very happy if we could at least kill off some of the ones that are not used regularly.

Yeah, I'd be happy too, that would simplify also my life.

Actually I was thinking of 2 defconfigs :
- one for platform_data based boards pxa2xx
- one for DT only boards pxa2xx

Quoted 1 line

lp8x4x seems to be the first pxa board which requires DT.

Most probably AFAIK.

Quoted 4 lines

We can create pxa27x-dt_defconfig which selects:
1. PXA27X_DT
2. PXA_FB and 8250_PXA to enable console
3. MMC, MMC_PXA and EXT4_FS to enable boot from MMC

If you put MMC_PXA, one can argue why not any MTD device used on pxa devices, such as pxa2xx-flash or docg3/docg4, etc ... I won't argue, I'm just pondering about the right choice.

Quoted 5 lines

4. all optional pxa stuff as modules
5. all stuff on supported pxa boards as modules

If #5 is extended when support for new boards is added, it should be possible to run any supported pxa27x board with pxa27x_defconfig.

I'm very eager to see a patch on that. I can feed my Jenkins with it, it would greatly help me catch issues earlier. Moreover it would for free test it on lubbock, mainstone and mioa701. If there was one also for pxa3xx, I would launch it on zylonite cm-x300 ... (that's a bonus, I know :))

Cheers.

Signature · 1 line
Robert
#277 lore raw

Re: [PATCH v5 2/2] arm: pxa27x: support for ICP DAS LP-8x4x w/ DT

Quoted 10 lines · Robert Jarzmik

?

Quoted 4 lines
Quoted 4 lines

Maybe we can have a pxa_defconfig file that enables lots of boards and then we remove the individual configs? We don't have to remove them all at once, but it would make me very happy if we could at least kill off some of the ones that are not used regularly.

Yeah, I'd be happy too, that would simplify also my life.

Actually I was thinking of 2 defconfigs :
?- one for platform_data based boards pxa2xx
?- one for DT only boards pxa2xx

I sincerely hope that dealing with ancient platform_data defconfigs is out of the scope this patch.

Quoted 7 lines
Quoted 1 line

lp8x4x seems to be the first pxa board which requires DT.

Most probably AFAIK.

Quoted 4 lines

We can create pxa27x-dt_defconfig which selects:
1. PXA27X_DT
2. PXA_FB and 8250_PXA to enable console
3. MMC, MMC_PXA and EXT4_FS to enable boot from MMC

Quoted 5 lines

If you put MMC_PXA, one can argue why not any MTD device used on pxa devices,
such as pxa2xx-flash or docg3/docg4, etc ... I won't argue, I'm just pondering
about the right choice.

Great point. We should enable MTD for sure. There is no PXA-specific MTD drivers, however. That's why MTD failed the grep test.

Quoted 6 lines
Quoted 5 lines

4. all optional pxa stuff as modules
5. all stuff on supported pxa boards as modules

If #5 is extended when support for new boards is added, it should be possible to run any supported pxa27x board with pxa27x_defconfig.

Quoted 8 lines

I'm very eager to see a patch on that. I can feed my Jenkins with it, it would
greatly help me catch issues earlier. Moreover it would for free test it on
lubbock, mainstone and mioa701. If there was one also for pxa3xx, I would launch
it on zylonite cm-x300 ... (that's a bonus, I know :))

Updated plan:
1. MACH_PXA27X_DT
2. PXA_FB and 8250_PXA to enable console
3. MMC, MMC_PXA and EXT4_FS to enable boot from MMC
3.1. MTD, MTD_CFI, MTD_PHYSMAP_OF and JFFS2_FS to enable boot from MTD
4. all optional pxa stuff as modules
5. all stuff on supported pxa boards as modules
6. supported boards should boot the kernel built with pxa27x-dt_defconfig after make olddefconfig

It is probably a good idea to put this plan somewhere in Documentation/ and to have a comment about that in the defconfig itself.

Is the plan acceptable?

maintainer
#278 lore raw

Re: [PATCH v5 2/2] arm: pxa27x: support for ICP DAS LP-8x4x w/ DT

Quoted 28 lines · On Tuesday 15 December 2015 21:50:13 Sergei Ianovich wrote:
Quoted 6 lines · Robert Jarzmik
Quoted 5 lines

4. all optional pxa stuff as modules
5. all stuff on supported pxa boards as modules

If #5 is extended when support for new boards is added, it should be possible to run any supported pxa27x board with pxa27x_defconfig.

Quoted 8 lines

I'm very eager to see a patch on that. I can feed my Jenkins with it, it would
greatly help me catch issues earlier. Moreover it would for free test it on
lubbock, mainstone and mioa701. If there was one also for pxa3xx, I would launch
it on zylonite cm-x300 ... (that's a bonus, I know :))

Updated plan:
1. MACH_PXA27X_DT
2. PXA_FB and 8250_PXA to enable console
3. MMC, MMC_PXA and EXT4_FS to enable boot from MMC
3.1. MTD, MTD_CFI, MTD_PHYSMAP_OF and JFFS2_FS to enable boot from MTD
4. all optional pxa stuff as modules
5. all stuff on supported pxa boards as modules
6. supported boards should boot the kernel built with pxa27x-dt_defconfig after make olddefconfig

Quoted 4 lines

It is probably a good idea to put this plan somewhere in Documentation/ and to have a comment about that in the defconfig itself.

Is the plan acceptable?

Sounds good to me.

Arnd

maintainer
#279 lore raw

Re: [PATCH v5 2/2] arm: pxa27x: support for ICP DAS LP-8x4x w/ DT

Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · On Tuesday 15 December 2015 21:50:13 Sergei Ianovich wrote:

On Tue, 2015-12-15 at 19:06 +0100, Robert Jarzmik wrote:
Updated plan:
1. MACH_PXA27X_DT
2. PXA_FB and 8250_PXA to enable console

What about gpio-pxa ? And maybe pinctrl-pxa27x (only in linux-next by now) ? Can a pxafb work without gpio-pxa ? Also usually for pxafb you have pwm and pwm_bl to see something.

Quoted 2 lines
Quoted 2 lines

3. MMC, MMC_PXA and EXT4_FS to enable boot from MMC
3.1. MTD, MTD_CFI, MTD_PHYSMAP_OF and JFFS2_FS to enable boot from MTD

Ok. Is pxa2xx-pcmcia out of scope ? I seem to remember we have several boards where pcmcia is the rootfs (even if that is a small mess right now I still have to work on). Or do we consider pcmcia as obsolete ?

Quoted 11 lines
Quoted 9 lines

4. all optional pxa stuff as modules
5. all stuff on supported pxa boards as modules
6. supported boards should boot the kernel built with pxa27x-dt_defconfig after make olddefconfig

It is probably a good idea to put this plan somewhere in Documentation/ and to have a comment about that in the defconfig itself.

Is the plan acceptable?

Sounds good to me.

Sounds good to me too.

Cheers.

Signature · 1 line
Robert
maintainer
#280 lore raw

Re: [PATCH v5 2/2] arm: pxa27x: support for ICP DAS LP-8x4x w/ DT

Quoted 11 lines · On Tuesday 15 December 2015 21:01:35 Robert Jarzmik wrote:
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · On Tuesday 15 December 2015 21:50:13 Sergei Ianovich wrote:

On Tue, 2015-12-15 at 19:06 +0100, Robert Jarzmik wrote:
Updated plan:
1. MACH_PXA27X_DT
2. PXA_FB and 8250_PXA to enable console

What about gpio-pxa ? And maybe pinctrl-pxa27x (only in linux-next by now) ? Can a pxafb work without gpio-pxa ? Also usually for pxafb you have pwm and pwm_bl to see something.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

3. MMC, MMC_PXA and EXT4_FS to enable boot from MMC
3.1. MTD, MTD_CFI, MTD_PHYSMAP_OF and JFFS2_FS to enable boot from MTD

Ok. Is pxa2xx-pcmcia out of scope ? I seem to remember we have several boards where pcmcia is the rootfs (even if that is a small mess right now I still have to work on). Or do we consider pcmcia as obsolete ?

I'm definitely fine with tossing in everything that is PXA specific, even if it's rarely used.

If someone wants a smaller kernel, they can still start out with the defconfig and disable stuff they don't need, which tends to be easier than the opposite, and it gives us compile-time coverage with the autobuilders that compile every defconfig.

Arnd

maintainer
#281 lore raw

Re: [PATCH v5 2/2] arm: pxa27x: support for ICP DAS LP-8x4x w/ DT

In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

I would like those drivers to be enabled in some defconfig, so we get compile-time coverage, but we generally stopped having one-config-per-board files.

Maybe we can have a pxa_defconfig file that enables lots of boards and then we remove the individual configs? We don't have to remove them all at once, but it would make me very happy if we could at least kill off some of the ones that are not used regularly.

I'll take that part, the pxa_defconfig which covers all pxa boards in arch/arm/mach-pxa. I have a prototype, which of course doesn't boot on any of my pxa platforms (breaks in the very early bootstrap code I think, DEBUG_LL is the next stage).

Actually I've not even looked if a single kernel covering pxa2xx and pxa3xx is possible (since recently clock handling was a blocker).

Once I have something that at least shows me a sign of life, I'll submit an RFC patch. This work will be orthogonal to Sergei's one, as it is aimed at having one defconfig compiling all mach-pxa/*.c files and the drivers referenced by them. This won't allow removing defconfig files until I have a good idea why my boards are not booting (lubbock, mainstone, mioa701, zylonite, cm-x300).

Cheers.

Signature · 1 line
Robert
#282 lore raw

PATCH 1/1 arm: pxa: create a unified defconfig for PXA27X-DT

In reply to Sergei Ianovich

Instead of one defconfig file per board, pxa27x-dt_defconfig is expected to provide a configuration for kernel which can test any PXA27X-DT compatible board

CC Robert Jarzmik <[email protected]>
CC Arnd Bergmann <[email protected]>
---
 Documentation/arm/pxa/pxa27x_defconfig.txt |   7 ++
 arch/arm/configs/pxa27x-dt_defconfig       | 102 +++++++++++++++++++++++++++++
 2 files changed, 109 insertions(+)
 create mode 100644 Documentation/arm/pxa/pxa27x_defconfig.txt
 create mode 100644 arch/arm/configs/pxa27x-dt_defconfig
Documentation/arm/pxa/pxa27x_defconfig.txt new file +7 -0
new file mode 100644
index 0000000..fc4e164
@@ -0,0 +1,7 @@
+If you are reading this, because you are adding support for a new
+PXA27X board, please note that you should not create an additional
+defconfig in arch/arm/configs.
+
+Instead, please update arch/arm/configs/pxa27x-dt_defconfig so that
+a kernel built with this config after `make olddefconfig` boots your
+board.
arch/arm/configs/pxa27x-dt_defconfig new file +102 -0

102 lines not on this page · raw message

Signature · 1 line
2.6.3
#283 lore raw

Re: [PATCH v2 02/11] arm: pxa27x: support ICP DAS LP-8x4x

In reply to Sergei Ianovich
Quoted 4 lines · Sergei Ianovich

ICP DAS calls LP-8x4x 'programmable automation controller'. It is an industrial computer based on PXA270 SoC. They ship it with a 2.6.19 kernel and proprietary kernel module and userspace library to access its industrial IO.

OK... so we only have device tree support for PXA3xx and noone is working on PXA2xx. And now we pile up some more legacy code. Such is life. But this:

Quoted 13 lines
arch/arm/mach-pxa/lp8x4x.c new file +13 -0
+static unsigned long lp8x4x_pin_config[] = {
+       /* MMC */
+       GPIO32_MMC_CLK,
+       GPIO112_MMC_CMD,
+       GPIO92_MMC_DAT_0,
+       GPIO109_MMC_DAT_1,
+       GPIO110_MMC_DAT_2,
+       GPIO111_MMC_DAT_3,
+
+       /* USB Host Port 1 */
+       GPIO88_USBH1_PWR,
+       GPIO89_USBH1_PEN,
+};

(...)

arch/arm/mach-pxa/lp8x4x.c line 416

Quoted 3 lines
arch/arm/mach-pxa/lp8x4x.c new file +3 -0
+static void __init lp8x4x_init(void)
+{
+       pxa2xx_mfp_config(ARRAY_AND_SIZE(lp8x4x_pin_config));

(...)

Argh! Now you're adding another user for a legacy custom pin control implementation. But if noone is going to modernize PXA2xx what can we do :-/

Yours,
Linus Walleij

#284 lore raw

Re: [PATCH v2 02/11] arm: pxa27x: support ICP DAS LP-8x4x

Quoted 3 lines · Linus Walleij

Argh! Now you're adding another user for a legacy custom pin control implementation. But if noone is going to modernize PXA2xx what can we do :-/

I've rewritten the device to use device tree and posted patch series for that.

I will also implement LP-8x4x custom irq controller in drivers/irqchip/

#285 lore raw

Re: [PATCH v2 02/11] arm: pxa27x: support ICP DAS LP-8x4x

Quoted 7 lines · Sergei Ianovich
Quoted 3 lines · Linus Walleij

Argh! Now you're adding another user for a legacy custom pin control implementation. But if noone is going to modernize PXA2xx what can we do :-/

I've rewritten the device to use device tree and posted patch series for that.

THANKS! For doing this.

Yours,
Linus Walleij

#286 lore raw

Re: [PATCH v2 02/11] arm: pxa27x: support ICP DAS LP-8x4x

In reply to Linus Walleij
Quoted 26 lines · Linus Walleij
Quoted 4 lines · Sergei Ianovich

ICP DAS calls LP-8x4x 'programmable automation controller'. It is an industrial computer based on PXA270 SoC. They ship it with a 2.6.19 kernel and proprietary kernel module and userspace library to access its industrial IO.

OK... so we only have device tree support for PXA3xx and noone is working on PXA2xx. And now we pile up some more legacy code. Such is life. But this:

Quoted 13 lines
arch/arm/mach-pxa/lp8x4x.c new file +13 -0
+static unsigned long lp8x4x_pin_config[] = {
+       /* MMC */
+       GPIO32_MMC_CLK,
+       GPIO112_MMC_CMD,
+       GPIO92_MMC_DAT_0,
+       GPIO109_MMC_DAT_1,
+       GPIO110_MMC_DAT_2,
+       GPIO111_MMC_DAT_3,
+
+       /* USB Host Port 1 */
+       GPIO88_USBH1_PWR,
+       GPIO89_USBH1_PEN,
+};

(...)

Quoted 8 lines

arch/arm/mach-pxa/lp8x4x.c line 416

Quoted 3 lines
arch/arm/mach-pxa/lp8x4x.c new file +3 -0
+static void __init lp8x4x_init(void)
+{
+       pxa2xx_mfp_config(ARRAY_AND_SIZE(lp8x4x_pin_config));

(...)

Argh! Now you're adding another user for a legacy custom pin control implementation. But if noone is going to modernize PXA2xx what can we do :-/

I tried a ~year ago, but it's not so trivial. PXA2xx has no separate pin control module, it's
highly integrated into GPIO controller. I've asked the maillist what should I do for that case, but AFAIR no one answered.

Regards
Vasily

Quoted 7 lines

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#287 lore raw

Re: [PATCH v2 02/11] arm: pxa27x: support ICP DAS LP-8x4x

Quoted 10 lines · Vasily Khoruzhick
Quoted 3 lines · Linus Walleij

Argh! Now you're adding another user for a legacy custom pin control implementation. But if noone is going to modernize PXA2xx what can we do :-/

I tried a ~year ago, but it's not so trivial. PXA2xx has no separate pin control module, it's
highly integrated into GPIO controller. I've asked the maillist what should I do for that case, but AFAIR no one answered.

It is very common for pin controllers and GPIO blocks to be integrated.

The usual solution is to make a combined driver that registers both pinctrl and GPIO interfaces and put that into drivers/pinctrl.

Here is a recent example that can be used as inspiration:
http://marc.info/?l=linux-doc&m=138629591206248&w=2

Yours,
Linus Walleij

#288 lore raw

Re: [PATCH v2 02/11] arm: pxa27x: support ICP DAS LP-8x4x

In reply to Linus Walleij
Quoted 3 lines · Linus Walleij

Argh! Now you're adding another user for a legacy custom pin control implementation. But if noone is going to modernize PXA2xx what can we do :-/

I plan to work on pxa2xx (pxa25x to be precise) after finishing with sa1100 - my second (well, first) PDA is Sharp SL-6000 (pxa255).

StrongARM somewhat resembles pxa2xx, so some of the drivers will be shared, some expertise will be shared, etc. I tried doing pxa first, but later found that it might be easier to update sa1100.

Signature · 2 lines
With best wishes
Dmitry
#289 lore raw

PATCH 3/11 rtc: support DS1302 RTC on ICP DAS LP-8x4x

In reply to Sergei Ianovich
---
 arch/arm/configs/lp8x4x_defconfig       |  1 +
 arch/arm/mach-pxa/include/mach/lp8x4x.h |  1 +
 arch/arm/mach-pxa/lp8x4x.c              |  8 ++++
 drivers/rtc/Kconfig                     |  2 +-
 drivers/rtc/rtc-ds1302.c                | 85 +++++++++++++++++++++++++++++++++
 5 files changed, 96 insertions(+), 1 deletion(-)
arch/arm/configs/lp8x4x_defconfig +1 -0
index 5cd6d38..27831e4 100644
@@ -1745,6 +1745,7 @@ CONFIG_RTC_INTF_DEV=y
 #
 # CONFIG_RTC_DRV_CMOS is not set
 # CONFIG_RTC_DRV_DS1286 is not set
+CONFIG_RTC_DRV_DS1302=y
 # CONFIG_RTC_DRV_DS1511 is not set
 # CONFIG_RTC_DRV_DS1553 is not set
 # CONFIG_RTC_DRV_DS1742 is not set
arch/arm/mach-pxa/include/mach/lp8x4x.h +1 -0
index 8c501fd..d8a1376 100644
@@ -48,6 +48,7 @@
 #define LP8X4X_CLRHILVINT	LP8X4X_P2V(0x17009016)
 #define LP8X4X_ENFALLINT	LP8X4X_P2V(0x17009018)
 #define LP8X4X_CLRFALLINT	LP8X4X_P2V(0x1700901a)
+#define LP8X4X_RWRTC		LP8X4X_P2V(0x1700901c)
 
 /* board specific IRQs */
 
arch/arm/mach-pxa/lp8x4x.c +8 -0
index 0b77e7a..a31b556 100644
@@ -386,11 +386,19 @@ static struct platform_device lp8x4x_dm9000_device[2] = {
 	},
 };
 
+static struct platform_device lp8x4x_ds1302_device[] = {
+	{
+		.name           = "rtc-ds1302",
+		.id             = 0,
+	},
+};
+
 static struct platform_device *lp8x4x_devices[] __initdata = {
 	&lp8x4x_flash_device[0],
 	&lp8x4x_flash_device[1],
 	&lp8x4x_dm9000_device[0],
 	&lp8x4x_dm9000_device[1],
+	&lp8x4x_ds1302_device[0],
 };
 
 static struct pxaohci_platform_data lp8x4x_ohci_platform_data = {
drivers/rtc/Kconfig +1 -1
index 0077302..59213c0 100644
@@ -676,7 +676,7 @@ config RTC_DRV_DS1286
 
 config RTC_DRV_DS1302
 	tristate "Dallas DS1302"
-	depends on SH_SECUREEDGE5410
+	depends on SH_SECUREEDGE5410 || MACH_LP8X4X
 	help
 	  If you say yes here you get support for the Dallas DS1302 RTC chips.
 
drivers/rtc/rtc-ds1302.c +85 -0

91 lines not on this page · raw message

Signature · 1 line
1.8.4.2
#290 lore raw

PATCH 4/11 mtd: support BB SRAM on ICP DAS LP-8x4x

In reply to Sergei Ianovich

This provides an MTD device driver for 512kB of battery backed up SRAM on ICPDAS LP-8X4X programmable automation controllers.

SRAM chip is connected via FPGA and is not accessible without a driver, unlike flash memory which is wired to CPU MMU.

This SRAM becomes an excellent persisent storage of volatile process data like counter values and sensor statuses. Storing those data in flash or mmc card is not a viable solution.

---
 arch/arm/configs/lp8x4x_defconfig       |   1 +
 arch/arm/mach-pxa/include/mach/lp8x4x.h |   2 +
 arch/arm/mach-pxa/lp8x4x.c              |  26 ++++
 drivers/mtd/devices/Kconfig             |  13 ++
 drivers/mtd/devices/Makefile            |   1 +
 drivers/mtd/devices/lp8x4x_sram.c       | 229 ++++++++++++++++++++++++++++++++
 6 files changed, 272 insertions(+)
 create mode 100644 drivers/mtd/devices/lp8x4x_sram.c
arch/arm/configs/lp8x4x_defconfig +1 -0
index 27831e4..03c85bc 100644
@@ -874,6 +874,7 @@ CONFIG_MTD_PXA2XX=y
 # Disk-On-Chip Device Drivers
 #
 # CONFIG_MTD_DOCG3 is not set
+CONFIG_MTD_LP8X4X_SRAM=y
 # CONFIG_MTD_NAND is not set
 # CONFIG_MTD_ONENAND is not set
 
arch/arm/mach-pxa/include/mach/lp8x4x.h +2 -0
index d8a1376..a49df22 100644
@@ -49,6 +49,8 @@
 #define LP8X4X_ENFALLINT	LP8X4X_P2V(0x17009018)
 #define LP8X4X_CLRFALLINT	LP8X4X_P2V(0x1700901a)
 #define LP8X4X_RWRTC		LP8X4X_P2V(0x1700901c)
+#define LP8X4X_SRAMBANK		0x1700901e
+#define LP8X4X_SRAM		0x1700a000
 
 /* board specific IRQs */
 
arch/arm/mach-pxa/lp8x4x.c +26 -0
index a31b556..47a8776 100644
@@ -234,6 +234,17 @@ static struct resource lp8x4x_flash_resources[] = {
 		.end	= PXA_CS1_PHYS + SZ_32M - 1,
 		.flags	= IORESOURCE_MEM,
 	},
+	[2] = {
+		.start  = LP8X4X_SRAMBANK,
+		.end    = LP8X4X_SRAMBANK + 1,
+		.flags  = IORESOURCE_MEM,
+	},
+	[3] = {
+		.start  = LP8X4X_SRAM,
+		.end    = LP8X4X_SRAM + SZ_4K - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+
 };
 
 static struct mtd_partition lp8x4x_flash0_partitions[] = {
@@ -267,6 +278,10 @@ static struct flash_platform_data lp8x4x_flash_data[] = {
 		.parts		= NULL,
 		.nr_parts	= 0,
 		.width		= 2,
+	}, {
+		.parts          = NULL,
+		.nr_parts       = 0,
+		.width          = 1,
 	}
 };
 
@@ -289,6 +304,16 @@ static struct platform_device lp8x4x_flash_device[] = {
 		.resource = &lp8x4x_flash_resources[1],
 		.num_resources = 1,
 	},
+	{
+		.name           = "lp8x4x-sram",
+		.id             = 0,
+		.dev = {
+			.platform_data = &lp8x4x_flash_data[2],
+		},
+		.resource = &lp8x4x_flash_resources[2],
+		.num_resources = 2,
+	},
+
 };
 
 static struct pxafb_mode_info lp8x4x_vga_60_mode = {
@@ -396,6 +421,7 @@ static struct platform_device lp8x4x_ds1302_device[] = {
 static struct platform_device *lp8x4x_devices[] __initdata = {
 	&lp8x4x_flash_device[0],
 	&lp8x4x_flash_device[1],
+	&lp8x4x_flash_device[2],
 	&lp8x4x_dm9000_device[0],
 	&lp8x4x_dm9000_device[1],
 	&lp8x4x_ds1302_device[0],
drivers/mtd/devices/Kconfig +13 -0
index 0128138..7da0c21 100644
@@ -217,4 +217,17 @@ config BCH_CONST_T
 	default 4
 endif
 
+config MTD_LP8X4X_SRAM
+       tristate "SRAM on ICPDAS LP-8X4X"
+       ---help---
+	 This provides an MTD device driver for 512kB of battery backed up SRAM
+	 on ICPDAS LP-8X4X programmable automation controllers.
+
+	 SRAM chip is connected via FPGA and is not accessible without a driver,
+	 unlike flash memory which is wired to CPU MMU.
+
+	 Say N, unless you plan to run this kernel on LP-8X4X.
+
+	 If you say M, the module will be called lp8x4x_sram.
+
 endmenu
drivers/mtd/devices/Makefile +1 -0
index d83bd73..8c5d9b0 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_MTD_NAND_OMAP_BCH)	+= elm.o
 obj-$(CONFIG_MTD_SPEAR_SMI)	+= spear_smi.o
 obj-$(CONFIG_MTD_SST25L)	+= sst25l.o
 obj-$(CONFIG_MTD_BCM47XXSFLASH)	+= bcm47xxsflash.o
+obj-$(CONFIG_MTD_LP8X4X_SRAM)	+= lp8x4x_sram.o
 
 
 CFLAGS_docg3.o			+= -I$(src)
drivers/mtd/devices/lp8x4x_sram.c new file +229 -0

229 lines not on this page · raw message

Signature · 1 line
1.8.4.2
#291 lore raw

PATCH 5/11 serial: support for 16550 serial ports on LP-8x4x

In reply to Sergei Ianovich

The patch adds support for 3 additional LP-8x4x built-in serial ports.

The device can also host up to 8 extension cards with 4 serial ports on each card for a total of 35 ports. However, I don't have the hardware to test extension cards, so they are not supported, yet.

---
 arch/arm/configs/lp8x4x_defconfig       |   1 +
 arch/arm/mach-pxa/include/mach/lp8x4x.h |   6 ++
 drivers/tty/serial/8250/8250_lp8x4x.c   | 181 ++++++++++++++++++++++++++++++++
 drivers/tty/serial/8250/Kconfig         |  11 ++
 drivers/tty/serial/8250/Makefile        |   1 +
 5 files changed, 200 insertions(+)
 create mode 100644 drivers/tty/serial/8250/8250_lp8x4x.c
arch/arm/configs/lp8x4x_defconfig +1 -0
index 03c85bc..d297a67 100644
@@ -1141,6 +1141,7 @@ CONFIG_SERIAL_8250_NR_UARTS=36
 CONFIG_SERIAL_8250_RUNTIME_UARTS=36
 CONFIG_SERIAL_8250_EXTENDED=y
 CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_LP8X4X=m
 CONFIG_SERIAL_8250_SHARE_IRQ=y
 # CONFIG_SERIAL_8250_DETECT_IRQ is not set
 # CONFIG_SERIAL_8250_RSA is not set
arch/arm/mach-pxa/include/mach/lp8x4x.h +6 -0
index a49df22..4d5474e 100644
@@ -50,6 +50,12 @@
 #define LP8X4X_CLRFALLINT	LP8X4X_P2V(0x1700901a)
 #define LP8X4X_RWRTC		LP8X4X_P2V(0x1700901c)
 #define LP8X4X_SRAMBANK		0x1700901e
+#define LP8X4X_TTYS0_QUIRK	0x17009030
+#define LP8X4X_TTYS1_QUIRK	0x17009032
+#define LP8X4X_TTYS2_QUIRK	0x17009034
+#define LP8X4X_TTYS0_IOMEM	0x17009050
+#define LP8X4X_TTYS1_IOMEM	0x17009060
+#define LP8X4X_TTYS2_IOMEM	0x17009070
 #define LP8X4X_SRAM		0x1700a000
 
 /* board specific IRQs */
drivers/tty/serial/8250/8250_lp8x4x.c new file +181 -0

181 lines not on this page · raw message

drivers/tty/serial/8250/Kconfig +11 -0
index f3b306e..30b9af4 100644
@@ -237,6 +237,17 @@ config SERIAL_8250_HUB6
 	  To compile this driver as a module, choose M here: the module
 	  will be called 8250_hub6.
 
+config SERIAL_8250_LP8X4X
+	tristate "Support 8250 ports on ICP DAS LP-8x4x"
+	depends on SERIAL_8250 != n && SERIAL_8250_MANY_PORTS && MACH_LP8X4X
+	help
+	  In addition on serial ports on PXA270 SoC, LP-8x4x has 1 dual
+	  RS232/RS485 port, 1 RS485 port and 1 RS232 port serial ports.
+
+	  Say N here, unless you plan to run this kernel on a LP-8x4x system.
+
+	  If you choose M, the module will be called 8250_lp8x4x.
+
 #
 # Misc. options/drivers.
 #
drivers/tty/serial/8250/Makefile +1 -0
index 36d68d0..451c558 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_SERIAL_8250_ACCENT)	+= 8250_accent.o
 obj-$(CONFIG_SERIAL_8250_BOCA)		+= 8250_boca.o
 obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554)	+= 8250_exar_st16c554.o
 obj-$(CONFIG_SERIAL_8250_HUB6)		+= 8250_hub6.o
+obj-$(CONFIG_SERIAL_8250_LP8X4X)	+= 8250_lp8x4x.o
 obj-$(CONFIG_SERIAL_8250_FSL)		+= 8250_fsl.o
 obj-$(CONFIG_SERIAL_8250_DW)		+= 8250_dw.o
 obj-$(CONFIG_SERIAL_8250_EM)		+= 8250_em.o
Signature · 1 line
1.8.4.2
#292 lore raw

Re: [PATCH 05/11] serial: support for 16550 serial ports on LP-8x4x

Hi,

Quoted 89 lines · Sergei Ianovich

The patch adds support for 3 additional LP-8x4x built-in serial ports.

The device can also host up to 8 extension cards with 4 serial ports on each card for a total of 35 ports. However, I don't have the hardware to test extension cards, so they are not supported, yet.

---
 arch/arm/configs/lp8x4x_defconfig       |   1 +
 arch/arm/mach-pxa/include/mach/lp8x4x.h |   6 ++
 drivers/tty/serial/8250/8250_lp8x4x.c   | 181 ++++++++++++++++++++++++++++++++
 drivers/tty/serial/8250/Kconfig         |  11 ++
 drivers/tty/serial/8250/Makefile        |   1 +
 5 files changed, 200 insertions(+)
 create mode 100644 drivers/tty/serial/8250/8250_lp8x4x.c
arch/arm/configs/lp8x4x_defconfig +1 -0
index 03c85bc..d297a67 100644
@@ -1141,6 +1141,7 @@ CONFIG_SERIAL_8250_NR_UARTS=36
 CONFIG_SERIAL_8250_RUNTIME_UARTS=36
 CONFIG_SERIAL_8250_EXTENDED=y
 CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_LP8X4X=m
 CONFIG_SERIAL_8250_SHARE_IRQ=y
 # CONFIG_SERIAL_8250_DETECT_IRQ is not set
 # CONFIG_SERIAL_8250_RSA is not set
arch/arm/mach-pxa/include/mach/lp8x4x.h +6 -0
index a49df22..4d5474e 100644
@@ -50,6 +50,12 @@
 #define LP8X4X_CLRFALLINT	LP8X4X_P2V(0x1700901a)
 #define LP8X4X_RWRTC		LP8X4X_P2V(0x1700901c)
 #define LP8X4X_SRAMBANK		0x1700901e
+#define LP8X4X_TTYS0_QUIRK	0x17009030
+#define LP8X4X_TTYS1_QUIRK	0x17009032
+#define LP8X4X_TTYS2_QUIRK	0x17009034
+#define LP8X4X_TTYS0_IOMEM	0x17009050
+#define LP8X4X_TTYS1_IOMEM	0x17009060
+#define LP8X4X_TTYS2_IOMEM	0x17009070
 #define LP8X4X_SRAM		0x1700a000
 
 /* board specific IRQs */
drivers/tty/serial/8250/8250_lp8x4x.c new file +37 -0
new file mode 100644
index 0000000..27b01f0b
@@ -0,0 +1,181 @@
+/*  linux/drivers/tty/serial/8250/8250_lp8x4x.c
+ *
+ *  Support for 16550 serial ports on ICP DAS LP-8x4x
+ *
+ *  Copyright (C) 2013 Sergei Ianovich <[email protected]>
+ *  Framework taken from linux/drivers/tty/serial/8250/8250_accent.c
+ *
+ *  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.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/delay.h>
+#include <linux/serial_8250.h>
+#include <mach/lp8x4x.h>
+#include <linux/io.h>
+
+#define QUIRK_PORT(_base, _irq)					\
+	{							\
+		.iobase		= _base,			\
+		.membase	= (void *) _base,		\
+		.mapbase	= _base,			\
+		.irq		= _irq,				\
+		.uartclk	= 14745600,			\
+		.regshift	= 1,				\
+		.iotype		= UPIO_MEM,			\
+		.flags		= UPF_IOREMAP,			\
+		.set_termios	= lp8x4x_set_termios,		\
+		.serial_in	= lp8x4x_serial_in,		\
+		.serial_out	= lp8x4x_serial_out,		\
+	}
+
+static void lp8x4x_set_termios(struct uart_port *port,
+		struct ktermios *termios, struct ktermios *old)
+{

<snip>

Quoted 71 lines
drivers/tty/serial/8250/8250_lp8x4x.c new file +71 -0
+}
+
+static unsigned int lp8x4x_serial_in(struct uart_port *p, int offset)
+{
+	unsigned int b;
+	udelay(30);
+	offset = offset << p->regshift;
+	b = readb(p->membase + offset);
+	return b;
+}
+
+static void lp8x4x_serial_out(struct uart_port *p, int offset, int value)
+{
+	offset = offset << p->regshift;
+	writeb(value, p->membase + offset);
+}
+
+static struct plat_serial8250_port lp8x4x_data[] = {
+	QUIRK_PORT(LP8X4X_TTYS0_IOMEM, LP8X4X_TTYS0_IRQ),
+	QUIRK_PORT(LP8X4X_TTYS1_IOMEM, LP8X4X_TTYS1_IRQ),
+	QUIRK_PORT(LP8X4X_TTYS2_IOMEM, LP8X4X_TTYS2_IRQ),
+	{ },
+};
+
+/* Total number of ports can be 35. The first 3 ports are on
+ * the device, the rest are on extension slots. Only the first 3
+ * require termios quirk */
+#define LP8X4X_QUIRK_PORTS	3
+
+static unsigned int extra_mem[LP8X4X_QUIRK_PORTS] = {
+	LP8X4X_TTYS0_QUIRK,
+	LP8X4X_TTYS1_QUIRK,
+	LP8X4X_TTYS2_QUIRK
+};
+
+static int request_and_remap(int i)
+{
+	if (!request_mem_region(extra_mem[i], 1, "serial"))
+		return -EBUSY;
+
+	lp8x4x_data[i].private_data = ioremap(extra_mem[i], 1);
+	if (lp8x4x_data[i].private_data)
+		return 0;
+
+	release_mem_region(extra_mem[i], 1);
+	return -ENODEV;
+}
+
+static void release_and_unmap(int i)
+{
+	iounmap((void *) lp8x4x_data[i].private_data);
+	release_mem_region(extra_mem[i], 1);
+}
+
+static struct platform_device lp8x4x_device = {
+	.name			= "serial8250",
+	.id			= PLAT8250_DEV_ACCENT,
+	.dev			= {
+		.platform_data	= lp8x4x_data,
+	},
+};
+
+static int __init lp8x4x_init(void)
+{
+	int i = 0;
+	int err = 0;
+
+	for (i = 0; i < LP8X4X_QUIRK_PORTS; i++) {
+		err = request_and_remap(i);
+		if (err == 0)
+			continue;

drivers/tty/serial/8250/8250_lp8x4x.c line 177

Quoted 10 lines
drivers/tty/serial/8250/8250_lp8x4x.c new file +10 -0
+
+		for (; i >= 0; i--)
+			release_and_unmap(i);
+		lp8x4x_device.dev.platform_data = NULL;
+		return err;
+	}
+	return platform_device_register(&lp8x4x_device);
+}
+
+module_init(lp8x4x_init);

Instead of registering a platform device for serial8250 here, you need to simply register a platform driver for something like lp8x4x_serial. The platform code will to registers the platform devices for it. You will use serial8250_register_8250_port() in your probe to register a new port. Use 8250_em.c and 8250_dw.c under drivers/tty/serial/8250/ as an example.

You don't need to introduce plat_serial8250_port so you won't need the QUIRK_PORT stuff. You deliver the iomem and the irq as normal resources that the driver uses when you create the platform device. That of course also means the driver does not need to care about the instances. The platform code will generate a platform device for as many ports you have and set to resources accordingly.

Thanks,

Signature · 1 line
heikki
#293 lore raw

Re: [PATCH 05/11] serial: support for 16550 serial ports on LP-8x4x

Quoted 46 lines · Heikki Krogerus
Quoted 23 lines · Sergei Ianovich

The patch adds support for 3 additional LP-8x4x built-in serial ports.

The device can also host up to 8 extension cards with 4 serial ports on each card for a total of 35 ports. However, I don't have the hardware to test extension cards, so they are not supported, yet.

arch/arm/mach-pxa/include/mach/lp8x4x.h +10 -0
@@ -50,6 +50,12 @@
 #define LP8X4X_CLRFALLINT	LP8X4X_P2V(0x1700901a)
 #define LP8X4X_RWRTC		LP8X4X_P2V(0x1700901c)
 #define LP8X4X_SRAMBANK		0x1700901e
+#define LP8X4X_TTYS0_QUIRK	0x17009030
+#define LP8X4X_TTYS1_QUIRK	0x17009032
+#define LP8X4X_TTYS2_QUIRK	0x17009034
+#define LP8X4X_TTYS0_IOMEM	0x17009050
+#define LP8X4X_TTYS1_IOMEM	0x17009060
+#define LP8X4X_TTYS2_IOMEM	0x17009070
+
+static void lp8x4x_set_termios(struct uart_port *port,
+		struct ktermios *termios, struct ktermios *old)
+{

<snip>

arch/arm/mach-pxa/include/mach/lp8x4x.h

Quoted 11 lines
arch/arm/mach-pxa/include/mach/lp8x4x.h +11 -0
+static int request_and_remap(int i)
+{
+	if (!request_mem_region(extra_mem[i], 1, "serial"))
+		return -EBUSY;
+
+	lp8x4x_data[i].private_data = ioremap(extra_mem[i], 1);
+	if (lp8x4x_data[i].private_data)
+		return 0;
+
+	release_mem_region(extra_mem[i], 1);
+	return -ENODEV;

Instead of registering a platform device for serial8250 here, you need to simply register a platform driver for something like lp8x4x_serial. The platform code will to registers the platform devices for it. You will use serial8250_register_8250_port() in your probe to register a new port. Use 8250_em.c and 8250_dw.c under drivers/tty/serial/8250/ as an example.

Quoted 6 lines

You don't need to introduce plat_serial8250_port so you won't need the QUIRK_PORT stuff. You deliver the iomem and the irq as normal resources that the driver uses when you create the platform device. That of course also means the driver does not need to care about the instances. The platform code will generate a platform device for as many ports you have and set to resources accordingly.

8250_core.c doesn't use platform infrastructure to request and map IO memory. There will be a conflict (and an error in serial8250_request_std_resource()), if main IO memory is requested by the platform device, won't it?

#294 lore raw

Re: [PATCH 05/11] serial: support for 16550 serial ports on LP-8x4x

Hi,

Quoted 28 lines · Sergei Ianovich
Quoted 20 lines · Heikki Krogerus

drivers/tty/serial/8250/8250_lp8x4x.c line 142

Quoted 11 lines · Sergei Ianovich
drivers/tty/serial/8250/8250_lp8x4x.c new file +11 -0
+static int request_and_remap(int i)
+{
+	if (!request_mem_region(extra_mem[i], 1, "serial"))
+		return -EBUSY;
+
+	lp8x4x_data[i].private_data = ioremap(extra_mem[i], 1);
+	if (lp8x4x_data[i].private_data)
+		return 0;
+
+	release_mem_region(extra_mem[i], 1);
+	return -ENODEV;

Instead of registering a platform device for serial8250 here, you need to simply register a platform driver for something like lp8x4x_serial. The platform code will to registers the platform devices for it. You will use serial8250_register_8250_port() in your probe to register a new port. Use 8250_em.c and 8250_dw.c under drivers/tty/serial/8250/ as an example.

Quoted 6 lines

You don't need to introduce plat_serial8250_port so you won't need the QUIRK_PORT stuff. You deliver the iomem and the irq as normal resources that the driver uses when you create the platform device. That of course also means the driver does not need to care about the instances. The platform code will generate a platform device for as many ports you have and set to resources accordingly.

Quoted 4 lines

8250_core.c doesn't use platform infrastructure to request and map IO memory. There will be a conflict (and an error in serial8250_request_std_resource()), if main IO memory is requested by the platform device, won't it?

You don't need to request the mem region in your probe driver.

You can still map it. You have the flag UPF_IOREMAP that you can use to tell 8250_code.c to map the region. If you don't set the flag, 8250_core.c will in practice expect that port->membase is already set by the probe driver.

Check 8250_dw.c. It does the mapping on it's own and simply doesn't set the flag.

Br,

Signature · 1 line
heikki
#295 lore raw

Re: [PATCH 05/11] serial: support for 16550 serial ports on LP-8x4x

In reply to Sergei Ianovich

drivers/tty/serial/8250/8250_lp8x4x.c line 153

Quoted 3 lines · Sergei Ianovich
drivers/tty/serial/8250/8250_lp8x4x.c new file +3 -0
+static struct platform_device lp8x4x_device = {
+	.name			= "serial8250",
+	.id			= PLAT8250_DEV_ACCENT,

You should not re-use the enum value here. The enum is designed as a method to provide the platform devices with a unique id, not as a means to identify the manufacturer or anything else like that.

#296 lore raw

Re: [PATCH 05/11] serial: support for 16550 serial ports on LP-8x4x

Quoted 8 lines · Russell King - ARM Linux

drivers/tty/serial/8250/8250_lp8x4x.c line 153

Quoted 3 lines · Sergei Ianovich
drivers/tty/serial/8250/8250_lp8x4x.c new file +3 -0
+static struct platform_device lp8x4x_device = {
+	.name			= "serial8250",
+	.id			= PLAT8250_DEV_ACCENT,

You should not re-use the enum value here. The enum is designed as a method to provide the platform devices with a unique id, not as a means to identify the manufacturer or anything else like that.

Should I add a new enum?

Or should I use zero?

#297 lore raw

Re: [PATCH 05/11] serial: support for 16550 serial ports on LP-8x4x

Quoted 11 lines · Sergei Ianovich
Quoted 8 lines · Russell King - ARM Linux

drivers/tty/serial/8250/8250_lp8x4x.c line 153

Quoted 3 lines · Sergei Ianovich
drivers/tty/serial/8250/8250_lp8x4x.c new file +3 -0
+static struct platform_device lp8x4x_device = {
+	.name			= "serial8250",
+	.id			= PLAT8250_DEV_ACCENT,

You should not re-use the enum value here. The enum is designed as a method to provide the platform devices with a unique id, not as a means to identify the manufacturer or anything else like that.

Should I add a new enum?

Add a new enum.

#298 lore raw

Re: [PATCH 05/11] serial: support for 16550 serial ports on LP-8x4x

Quoted 1 line · Russell King - ARM Linux

Add a new enum.

I will. Thanks for prompt replies.

A side work process question:
Should I respin this single patch?

Or should I wait for other patch reviews and respin the whole series when ready?

#299 lore raw

PATCH 6/11 misc: support for LP-8x4x custom parallel bus

In reply to Sergei Ianovich

This patch implements probing for the bus and reporting the number of available expansion slots.

---
 Documentation/misc-devices/lp8x4x_bus.txt |  30 ++++++
 arch/arm/configs/lp8x4x_defconfig         |   1 +
 arch/arm/mach-pxa/include/mach/lp8x4x.h   |   1 +
 arch/arm/mach-pxa/lp8x4x.c                |  18 ++++
 drivers/misc/Kconfig                      |  12 +++
 drivers/misc/Makefile                     |   1 +
 drivers/misc/lp8x4x_bus.c                 | 165 ++++++++++++++++++++++++++++++
 7 files changed, 228 insertions(+)
 create mode 100644 Documentation/misc-devices/lp8x4x_bus.txt
 create mode 100644 drivers/misc/lp8x4x_bus.c
Documentation/misc-devices/lp8x4x_bus.txt new file +30 -0
new file mode 100644
index 0000000..f5392b3
@@ -0,0 +1,30 @@
+Kernel driver lpx8x4x_bus
+======================
+
+Supported hardare:
+Custom parallel bus on ICP DAS LP-8x4x industrial computers
+
+Data sheet:
+Not freely available
+
+Author:
+Sergei Ianovich <[email protected]>
+
+Description
+-----------
+
+http://www.icpdas.com/root/product/solutions/pac/linpac/lp-8x4x_hardware.html
+
+LP-8x4x is an ARM-based industrial computer with a custom parallel bus to
+connect expansion modules with digital input/output, analog input/output,
+serial, CAN and other types of ports.
+
+The bus is implemented by a FPGA.
+
+SYSFS
+-----
+
+/sys/bus/icpdas/devices/backplane:
+
+slot_count
+	RO - shows total number of expansion slots on the device
arch/arm/configs/lp8x4x_defconfig +1 -0
index d297a67..5f2b842 100644
@@ -921,6 +921,7 @@ CONFIG_BLK_DEV_LOOP_MIN_COUNT=2
 # CONFIG_BMP085_I2C is not set
 # CONFIG_USB_SWITCH_FSA9480 is not set
 # CONFIG_SRAM is not set
+CONFIG_LP8X4X_BUS=m
 # CONFIG_C2PORT is not set
 
 #
arch/arm/mach-pxa/include/mach/lp8x4x.h +1 -0
index 4d5474e..5d289bf 100644
@@ -53,6 +53,7 @@
 #define LP8X4X_TTYS0_QUIRK	0x17009030
 #define LP8X4X_TTYS1_QUIRK	0x17009032
 #define LP8X4X_TTYS2_QUIRK	0x17009034
+#define LP8X4X_MOD_NUM		0x17009046
 #define LP8X4X_TTYS0_IOMEM	0x17009050
 #define LP8X4X_TTYS1_IOMEM	0x17009060
 #define LP8X4X_TTYS2_IOMEM	0x17009070
arch/arm/mach-pxa/lp8x4x.c +18 -0
index 47a8776..38482d3 100644
@@ -418,6 +418,23 @@ static struct platform_device lp8x4x_ds1302_device[] = {
 	},
 };
 
+static struct resource lp8x4x_bus_resources[] = {
+	[0] = {
+		.start  = LP8X4X_MOD_NUM,
+		.end    = LP8X4X_MOD_NUM,
+		.flags  = IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device lp8x4x_bus_device[] = {
+	{
+		.name           = "lp8x4x-bus",
+		.id             = 0,
+		.resource = &lp8x4x_bus_resources[0],
+		.num_resources = 1,
+	},
+};
+
 static struct platform_device *lp8x4x_devices[] __initdata = {
 	&lp8x4x_flash_device[0],
 	&lp8x4x_flash_device[1],
@@ -425,6 +442,7 @@ static struct platform_device *lp8x4x_devices[] __initdata = {
 	&lp8x4x_dm9000_device[0],
 	&lp8x4x_dm9000_device[1],
 	&lp8x4x_ds1302_device[0],
+	&lp8x4x_bus_device[0],
 };
 
 static struct pxaohci_platform_data lp8x4x_ohci_platform_data = {
drivers/misc/Kconfig +12 -0
index a3e291d..85676c4 100644
@@ -515,6 +515,18 @@ config SRAM
 	  the genalloc API. It is supposed to be used for small on-chip SRAM
 	  areas found on many SoCs.
 
+config LP8X4X_BUS
+	tristate "ICP DAS LP-8x4x industrial IO bus"
+	depends on MACH_LP8X4X && SYSFS
+	---help---
+	  This is a driver for ICP DAS LP-8x4x programmable automation
+	  controller. It exposes a custom parallel bus. The bus services
+	  data acquisition and control modules.
+
+	  Say N, unless you plan to run this kernel on a LP-8x4x system.
+
+	  If you say M here, the module will be called lp8x4x_bus.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
index f45473e..7578cff 100644
@@ -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_LP8X4X_BUS)	+= lp8x4x_bus.o
drivers/misc/lp8x4x_bus.c new file +165 -0

165 lines not on this page · raw message

Signature · 1 line
1.8.4.2
#300 lore raw

PATCH 7/11 misc: support for serial slots in LP-8x4x

In reply to Sergei Ianovich

Serial modules (I-870xxW series) implement DCON protocol which allows one-master-many-slaves configuration over RS-485. When these modules are installed into the device, they could be accessed using the 2nd PXA built-in UART port (/dev/ttySA1). However, it seems that addresses are not processed by the modules. So the parallel bus needs to select which slot is connected.

---
 Documentation/misc-devices/lp8x4x_bus.txt | 15 ++++++-
 arch/arm/mach-pxa/include/mach/lp8x4x.h   |  1 +
 arch/arm/mach-pxa/lp8x4x.c                |  7 ++-
 drivers/misc/lp8x4x_bus.c                 | 73 +++++++++++++++++++++++++++++--
 4 files changed, 90 insertions(+), 6 deletions(-)
Documentation/misc-devices/lp8x4x_bus.txt +14 -1
index f5392b3..d9a069d 100644
@@ -19,7 +19,14 @@ LP-8x4x is an ARM-based industrial computer with a custom parallel bus to
 connect expansion modules with digital input/output, analog input/output,
 serial, CAN and other types of ports.
 
-The bus is implemented by a FPGA.
+The bus is implemented by a FPGA. There are two major groups of expansion
+modules: serial and parallel.
+
+Serial modules (I-870xxW series) implement DCON protocol which allows one-
+master-many-slaves configuration over RS-485. When these modules are installed
+into the device, they could be accessed using the 2nd PXA built-in UART port
+(/dev/ttySA1). However, it seems that addresses are not processed by
+the modules. So the parallel bus needs to select which slot is connected.
 
 SYSFS
 -----
@@ -28,3 +35,9 @@ SYSFS
 
 slot_count
 	RO - shows total number of expansion slots on the device
+
+active_slot
+	RW - connects the select slot for serial communications. If there
+	     is a parallel module in the selected slot, it simply ignores
+	     incoming packets. So it is safe to activate any available
+	     slot.
arch/arm/mach-pxa/include/mach/lp8x4x.h +1 -0
index 5d289bf..9addfa8 100644
@@ -37,6 +37,7 @@
 
 /* board level registers in the FPGA */
 
+#define LP8X4X_SLOT_SWITCH	0x17009004
 #define LP8X4X_EOI		LP8X4X_P2V(0x17009006)
 #define LP8X4X_INSINT		LP8X4X_P2V(0x17009008)
 #define LP8X4X_ENSYSINT		LP8X4X_P2V(0x1700900A)
arch/arm/mach-pxa/lp8x4x.c +6 -1
index 38482d3..b30343d 100644
@@ -424,6 +424,11 @@ static struct resource lp8x4x_bus_resources[] = {
 		.end    = LP8X4X_MOD_NUM,
 		.flags  = IORESOURCE_MEM,
 	},
+	[1] = {
+		.start  = LP8X4X_SLOT_SWITCH,
+		.end    = LP8X4X_SLOT_SWITCH,
+		.flags  = IORESOURCE_MEM,
+	},
 };
 
 static struct platform_device lp8x4x_bus_device[] = {
@@ -431,7 +436,7 @@ static struct platform_device lp8x4x_bus_device[] = {
 		.name           = "lp8x4x-bus",
 		.id             = 0,
 		.resource = &lp8x4x_bus_resources[0],
-		.num_resources = 1,
+		.num_resources = 2,
 	},
 };
 
drivers/misc/lp8x4x_bus.c +69 -4

134 lines not on this page · raw message

Signature · 1 line
1.8.4.2
#301 lore raw

PATCH 8/11 misc: support for parallel slots in LP-8x4x

In reply to Sergei Ianovich

This patch enumerates parallel modules in expansion slots and exposes model numbers via sysfs.

---
 Documentation/misc-devices/lp8x4x_bus.txt |   8 ++
 arch/arm/mach-pxa/include/mach/lp8x4x.h   |   8 ++
 arch/arm/mach-pxa/lp8x4x.c                |  42 +++++++++-
 drivers/misc/lp8x4x_bus.c                 | 127 ++++++++++++++++++++++++++++++
 4 files changed, 184 insertions(+), 1 deletion(-)
Documentation/misc-devices/lp8x4x_bus.txt +8 -0
index d9a069d..9285fdc 100644
@@ -28,6 +28,9 @@ into the device, they could be accessed using the 2nd PXA built-in UART port
 (/dev/ttySA1). However, it seems that addresses are not processed by
 the modules. So the parallel bus needs to select which slot is connected.
 
+Parallel modules allow much faster communication. There are accessed using
+IO memory through the FPGA. Their ports are exposed via sysfs.
+
 SYSFS
 -----
 
@@ -41,3 +44,8 @@ active_slot
 	     is a parallel module in the selected slot, it simply ignores
 	     incoming packets. So it is safe to activate any available
 	     slot.
+
+/sys/bus/icpdas/devices/slot%02i:
+
+model
+	RO - shows expansion module model number
arch/arm/mach-pxa/include/mach/lp8x4x.h +8 -0
index 9addfa8..e1005c5 100644
@@ -37,6 +37,14 @@
 
 /* board level registers in the FPGA */
 
+#define LP8X4X_SLOT1_IO		0x17001000
+#define LP8X4X_SLOT2_IO		0x17002000
+#define LP8X4X_SLOT3_IO		0x17003000
+#define LP8X4X_SLOT4_IO		0x17004000
+#define LP8X4X_SLOT5_IO		0x17005000
+#define LP8X4X_SLOT6_IO		0x17006000
+#define LP8X4X_SLOT7_IO		0x17007000
+#define LP8X4X_SLOT8_IO		0x17008000
 #define LP8X4X_SLOT_SWITCH	0x17009004
 #define LP8X4X_EOI		LP8X4X_P2V(0x17009006)
 #define LP8X4X_INSINT		LP8X4X_P2V(0x17009008)
arch/arm/mach-pxa/lp8x4x.c +41 -1

54 lines not on this page · raw message

drivers/misc/lp8x4x_bus.c +127 -0

180 lines not on this page · raw message

Signature · 1 line
1.8.4.2
#302 lore raw

PATCH 9/11 misc: support for I-8041 in LP-8x4x

In reply to Sergei Ianovich

Status of I-8041 32 digital output channels can be managed via sysfs now.

http://www.icpdas.com/products/Remote_IO/i-8ke/i-8041w.htm

---
 Documentation/misc-devices/lp8x4x_bus.txt |  4 ++
 drivers/misc/lp8x4x_bus.c                 | 67 ++++++++++++++++++++++++++++++-
 2 files changed, 69 insertions(+), 2 deletions(-)
Documentation/misc-devices/lp8x4x_bus.txt +4 -0
index 9285fdc..74df10b 100644
@@ -49,3 +49,7 @@ active_slot
 
 model
 	RO - shows expansion module model number
+
+output_status
+	RW - set status of digital output channels on the module in
+	     the expansion slot. Value can be read back.
drivers/misc/lp8x4x_bus.c +65 -2

104 lines not on this page · raw message

Signature · 1 line
1.8.4.2
#303 lore raw

PATCH 10/11 misc: support for I-8042 in LP-8x4x

In reply to Sergei Ianovich

Status of I-8042 16 digital output channels can be managed via sysfs.

Status of I-8042 16 digital input channels can be read via sysfs.

http://www.icpdas.com/products/Remote_IO/i-8ke/i-8042w.htm

---
 Documentation/misc-devices/lp8x4x_bus.txt |  4 ++
 drivers/misc/lp8x4x_bus.c                 | 76 ++++++++++++++++++++++++++++++-
 2 files changed, 78 insertions(+), 2 deletions(-)
Documentation/misc-devices/lp8x4x_bus.txt +4 -0
index 74df10b..e3a8bcf 100644
@@ -50,6 +50,10 @@ active_slot
 model
 	RO - shows expansion module model number
 
+input_status
+	RO - get status of digital input channels on the module in
+	     the expansion slot.
+
 output_status
 	RW - set status of digital output channels on the module in
 	     the expansion slot. Value can be read back.
drivers/misc/lp8x4x_bus.c +74 -2

127 lines not on this page · raw message

Signature · 1 line
1.8.4.2
#304 lore raw

PATCH 11/11 misc: support for I-8024 in LP-8x4x

In reply to Sergei Ianovich

Status of I-8042 4 analog output channels can be managed via sysfs.

http://www.icpdas.com/root/product/solutions/remote_io/rs-485/i-8k_i-87k/i-8024w.html

---
 Documentation/misc-devices/lp8x4x_bus.txt | 15 ++++++
 drivers/misc/lp8x4x_bus.c                 | 89 +++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+)
Documentation/misc-devices/lp8x4x_bus.txt +15 -0
index e3a8bcf..08419d1 100644
@@ -57,3 +57,18 @@ input_status
 output_status
 	RW - set status of digital output channels on the module in
 	     the expansion slot. Value can be read back.
+
+analog_output
+	RW - set status of analog output channels on the module in
+	     the expansion slot. Tested with voltage output. Bits 0-13:
+	     0x00c0 is -10.0V
+	     0x2000 is   0.0V
+	     0x3f40 is +10.0V
+
+	     So 1 unit of output is 1.25 mV.
+
+	     Bits 15 and 14 determine which channel to apply the value:
+	     0x0000 is channel 1
+	     0x4000 is channel 2
+	     0x8000 is channel 3
+	     0xc000 is channel 4
drivers/misc/lp8x4x_bus.c +89 -0

131 lines not on this page · raw message

Signature · 1 line
1.8.4.2