fsl upm, nand driver and MPC8360E-RDK as its first user
Subsystems (5)
cover fsl upm, nand driver and MPC8360E-RDK as its first user
Hi all,
Here is the FSL UPM infrastructure and FSL UPM NAND driver which is using it. This patchset depends on GPIO API.
Changes since RFC:
- Lockless variant removed;
- Implemented "width" property;
- Few cosmetic changes.
Thanks,
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2
PATCH 1/3 FSL UPM: routines to manage FSL UPMs
Here are few routines needed to manage FSL UPMs. It doesn't include UPM programming, yet. So far u-boot manages to program everything.
--- arch/powerpc/Kconfig | 3 + arch/powerpc/sysdev/Makefile | 1 + arch/powerpc/sysdev/fsl_upm.c | 65 +++++++++++++++++++++++++++++ include/asm-powerpc/fsl_upm.h | 90 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/sysdev/fsl_upm.c create mode 100644 include/asm-powerpc/fsl_upm.h
arch/powerpc/Kconfig +3 -0
@@ -463,6 +463,9 @@ config FSL_PCI bool select PPC_INDIRECT_PCI +config FSL_UPM + bool + # Yes MCA RS/6000s exist but Linux-PPC does not currently support any config MCA bool
arch/powerpc/sysdev/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_U3_DART) += dart_iommu.o obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o obj-$(CONFIG_FSL_SOC) += fsl_soc.o obj-$(CONFIG_FSL_PCI) += fsl_pci.o +obj-$(CONFIG_FSL_UPM) += fsl_upm.o obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o obj-$(CONFIG_QUICC_ENGINE) += qe_lib/ obj-$(CONFIG_PPC_BESTCOMM) += bestcomm/
arch/powerpc/sysdev/fsl_upm.c new file +65 -0
65 lines not on this page · raw message
include/asm-powerpc/fsl_upm.h new file +90 -0
90 lines not on this page · raw message
Signature · 1 line
1.5.2.2
Re: [PATCH 1/3] [POWERPC] FSL UPM: routines to manage FSL UPMs
Quoted 18 lines · Anton Vorontsov
Here are few routines needed to manage FSL UPMs. It doesn't include UPM programming, yet. So far u-boot manages to program everything.
Signed-off-by Anton Vorontsov <[email protected]>--- arch/powerpc/Kconfig | 3 + arch/powerpc/sysdev/Makefile | 1 + arch/powerpc/sysdev/fsl_upm.c | 65 +++++++++++++++++++++++++++++ include/asm-powerpc/fsl_upm.h | 90 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/sysdev/fsl_upm.c create mode 100644 include/asm-powerpc/fsl_upm.harch/powerpc/Kconfig +0
-0
arch/powerpc/Kconfig config FSL_PCI · line 467
Quoted 5 lines
arch/powerpc/Kconfig +2
-0@@ -463,6 +463,9 @@ config FSL_PCI bool select PPC_INDIRECT_PCI +config FSL_UPM + bool
Please describe new config options, even if they're silent ones.
-Olof
Re: [PATCH 1/3] [POWERPC] FSL UPM: routines to manage FSL UPMs
In reply to Anton VorontsovQuoted 6 lines · On Fri, 21 Dec 2007 23:39:25 +0300 Anton Vorontsov <[email protected]>…
arch/powerpc/sysdev/fsl_upm.c new file +5
-0+int fsl_upm_get_for (struct device_node *node,const char *name, +struct fsl_upm *upm) +{ +int ret; +struct device_node *lbus;
arch/powerpc/sysdev/fsl_upm.c line 34
Quoted 10 lines
arch/powerpc/sysdev/fsl_upm.c new file +10
-0+struct resource lbc_res; +ptrdiff_t mxmr_offs; + + lbus =of_get_parent (node); +if (!lbus) { +pr_err ("FSL UPM: can't get parent local bus node\n" ); +return -ENOENT ; + } + + ret =of_address_to_resource (lbus,0 , &lbc_res);
of_node_put(lbus) as of_get_parent() gets a reference.
include/asm-powerpc/fsl_upm.h line 51
Quoted 3 lines
include/asm-powerpc/fsl_upm.h new file +3
-0+static inline void fsl_upm_start_pattern (struct fsl_upm *upm,u32 pat_offset) +{ +spin_lock_irqsave (&upm_lock, upm_lock_flags);
I may be wrong, but don't we need the "flags" argument to spin_lock_irqsave to be on the stack? And the save and restore to be in the same function?
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Re: [PATCH 1/3] [POWERPC] FSL UPM: routines to manage FSL UPMs
Quoted 11 lines · Stephen Rothwell
Quoted 10 lines · On Fri, 21 Dec 2007 23:39:25 +0300 Anton Vorontsov <[email protected]>…
arch/powerpc/sysdev/fsl_upm.c new file +9
-0+int fsl_upm_get_for (struct device_node *node,const char *name, +struct fsl_upm *upm) +{ +int ret; +struct device_node *lbus; +struct resource lbc_res; +ptrdiff_t mxmr_offs; + + lbus =of_get_parent (node);
Quoted 8 lines
arch/powerpc/sysdev/fsl_upm.c line 34
Quoted 6 lines
arch/powerpc/sysdev/fsl_upm.c new file +6
-0+if (!lbus) { +pr_err ("FSL UPM: can't get parent local bus node\n" ); +return -ENOENT ; + } + + ret =of_address_to_resource (lbus,0 , &lbc_res);
of_node_put(lbus)asof_get_parent()gets a reference.
Thanks, will fix.
Quoted 7 lines
include/asm-powerpc/fsl_upm.h line 51
Quoted 3 lines
include/asm-powerpc/fsl_upm.h new file +3
-0+static inline void fsl_upm_start_pattern (struct fsl_upm *upm,u32 pat_offset) +{ +spin_lock_irqsave (&upm_lock, upm_lock_flags);I may be wrong, but don't we need the "flags" argument to
spin_lock_irqsaveto be on the stack? And the save and restore to be in the same function?
In general case, yes. Here, not exactly. We have to grab a lock at the start(), do runs(), and release a lock at the end():
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2
Re: [PATCH 1/3] [POWERPC] FSL UPM: routines to manage FSL UPMs
On Sun, Dec 23, 2007 at 02:59:35PM +0300, Anton Vorontsov wrote:
[..]
Quoted 10 lines
Quoted 7 lines
include/asm-powerpc/fsl_upm.h line 51
Quoted 3 lines
include/asm-powerpc/fsl_upm.h new file +3
-0+static inline void fsl_upm_start_pattern (struct fsl_upm *upm,u32 pat_offset) +{ +spin_lock_irqsave (&upm_lock, upm_lock_flags);I may be wrong, but don't we need the "flags" argument to
spin_lock_irqsaveto be on the stack? And the save and restore to be in the same function?In general case, yes. Here, not exactly. We have to grab a lock at the
start(), doruns(), and release a lock at theend():
Ugh, that's stupid of course. flags are indeed should be on the stack. So, what I can use here is a mutex, and thus forbid using these routines from the isrs. Another option would be disabling interrupts and getting plain lock, but that is ugly. So will use a mutex.
Much thanks,
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2
Re: [PATCH 1/3] [POWERPC] FSL UPM: routines to manage FSL UPMs
Quoted 10 lines · Anton Vorontsov
On Sun, Dec 23, 2007 at 02:59:35PM +0300, Anton Vorontsov wrote:
[..]Quoted 8 lines
Quoted 7 lines
include/asm-powerpc/fsl_upm.h line 51
Quoted 3 lines
include/asm-powerpc/fsl_upm.h new file +3
-0+static inline void fsl_upm_start_pattern (struct fsl_upm *upm,u32 pat_offset) +{ +spin_lock_irqsave (&upm_lock, upm_lock_flags);I may be wrong, but don't we need the "flags" argument to
spin_lock_irqsaveto be on the stack? And the save and restore to be in the same function?
Quoted 7 lines
Quoted 2 lines
In general case, yes. Here, not exactly. We have to grab a lock at the
start(), doruns(), and release a lock at theend():Ugh, that's stupid of course. flags are indeed should be on the stack. So, what I can use here is a mutex, and thus forbid using these routines from the isrs. Another option would be disabling interrupts and getting plain lock, but that is ugly. So will use a mutex.
Ignore me please, I should had more sleep today. For God's sake, why I've just said a "mutex"?.. I should just get a plain lock and forget about isrs.
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2
PATCH 2/3 FSL UPM NAND driver
In reply to Anton VorontsovIt's using FSL UPM infrastructure. So far only 8 bit accessors are implemented.
--- drivers/mtd/nand/Kconfig | 7 + drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/fsl_upm.c | 313 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 321 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/nand/fsl_upm.c
drivers/mtd/nand/Kconfig +7 -0
@@ -306,4 +306,11 @@ config MTD_ALAUDA These two (and possibly other) Alauda-based cardreaders for SmartMedia and xD allow raw flash access. +config MTD_NAND_FSL_UPM + tristate "MTD driver for NAND on Freescale UPM" + depends on MTD_NAND && FSL_UPM && GENERIC_GPIO + help + Enables support for NAND Flash wired to Freescale processors' + localbus with pre-programmed User-Programmable Machine. + endif # MTD_NAND
drivers/mtd/nand/Makefile +1 -0
@@ -29,5 +29,6 @@ obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o obj-$(CONFIG_MTD_NAND_BASLER_EXCITE) += excite_nandflash.o obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o obj-$(CONFIG_MTD_ALAUDA) += alauda.o +obj-$(CONFIG_MTD_NAND_FSL_UPM) += fsl_upm.o nand-objs := nand_base.o nand_bbt.o
drivers/mtd/nand/fsl_upm.c new file +313 -0
313 lines not on this page · raw message
Signature · 1 line
1.5.2.2
Re: [PATCH 2/3] [POWERPC][NAND] FSL UPM NAND driver
Quoted 14 lines · On Fri, 21 Dec 2007 23:41:30 +0300 Anton Vorontsov <[email protected]>…
drivers/mtd/nand/fsl_upm.c new file +13
-0+static int __devinit upm_chip_probe (struct of_device *ofdev, +const struct of_device_id *ofid) +{ +struct upm_data *ud; +struct resource io_res; +const u32 *prop; +int ret; +int size; + + ud =kzalloc (sizeof (*ud),GFP_KERNEL ); +if (!ud) +return -ENOMEM ; +
drivers/mtd/nand/fsl_upm.c line 184
Quoted 10 lines
drivers/mtd/nand/fsl_upm.c new file +10
-0+ ret =of_address_to_resource (ofdev->node,0 , &io_res); +if (ret) { +dev_err (&ofdev->dev,"can't get IO base\n" ); + goto err; + } + + prop =of_get_property (ofdev->node,"width" , &size); +if (!prop || size !=sizeof (u32)) { +dev_err (&ofdev->dev,"can't get chip width\n" ); + goto err;
Here ret is 0, is that the correct return code?
drivers/mtd/nand/fsl_upm.c line 227
Quoted 11 lines
drivers/mtd/nand/fsl_upm.c new file +11
-0+ ud->rnb_gpio =of_get_gpio (ofdev->node,0 ); +if (ud->rnb_gpio >=0 ) { + ret =gpio_request (ud->rnb_gpio, ofdev->dev.bus_id); +if (ret) { +dev_err (&ofdev->dev,"can't request RNB gpio\n" ); + goto err; + } +gpio_direction_input (ud->rnb_gpio); + }else if (ud->rnb_gpio == -EINVAL ) { +dev_err (&ofdev->dev,"specified RNB gpio is invalid\n" ); + goto err;
Again ret is 0 here.
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Re: [PATCH 2/3] [POWERPC][NAND] FSL UPM NAND driver
Quoted 19 lines · Stephen Rothwell
Quoted 18 lines · On Fri, 21 Dec 2007 23:41:30 +0300 Anton Vorontsov <[email protected]>…
drivers/mtd/nand/fsl_upm.c new file +17
-0+static int __devinit upm_chip_probe (struct of_device *ofdev, +const struct of_device_id *ofid) +{ +struct upm_data *ud; +struct resource io_res; +const u32 *prop; +int ret; +int size; + + ud =kzalloc (sizeof (*ud),GFP_KERNEL ); +if (!ud) +return -ENOMEM ; + + ret =of_address_to_resource (ofdev->node,0 , &io_res); +if (ret) { +dev_err (&ofdev->dev,"can't get IO base\n" ); + goto err;
Quoted 8 lines
drivers/mtd/nand/fsl_upm.c line 184
Quoted 6 lines
drivers/mtd/nand/fsl_upm.c new file +6
-0+ } + + prop =of_get_property (ofdev->node,"width" , &size); +if (!prop || size !=sizeof (u32)) { +dev_err (&ofdev->dev,"can't get chip width\n" ); + goto err;Here ret is 0, is that the correct return code?
Nope.
Quoted 5 lines
Quoted 5 lines
drivers/mtd/nand/fsl_upm.c new file +5
-0+ ud->rnb_gpio =of_get_gpio (ofdev->node,0 ); +if (ud->rnb_gpio >=0 ) { + ret =gpio_request (ud->rnb_gpio, ofdev->dev.bus_id); +if (ret) { +dev_err (&ofdev->dev,"can't request RNB gpio\n" );
Quoted 8 lines
drivers/mtd/nand/fsl_upm.c line 227
Quoted 6 lines
drivers/mtd/nand/fsl_upm.c new file +6
-0+ goto err; + } +gpio_direction_input (ud->rnb_gpio); + }else if (ud->rnb_gpio == -EINVAL ) { +dev_err (&ofdev->dev,"specified RNB gpio is invalid\n" ); + goto err;Again ret is 0 here.
Much thanks for catching that!
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2
PATCH 3/3 MPC8360E-RDK: add support for NAND on UPM
In reply to Anton Vorontsov--- arch/powerpc/boot/dts/mpc836x_rdk.dts | 19 +++++++++++++++++-- arch/powerpc/platforms/83xx/Kconfig | 1 + 2 files changed, 18 insertions(+), 2 deletions(-)
arch/powerpc/boot/dts/mpc836x_rdk.dts +17 -2
@@ -126,7 +126,8 @@ reg = <0x700 0x100>; }; - par_io@1400 { + qe_pio: par_io@1400 { + #gpio-cells = <2>; compatible = "fsl,qe-pario"; reg = <0x1400 0x100>; num-ports = <7>;
@@ -292,7 +293,8 @@ compatible = "fsl,mpc8360-localbus", "fsl,pq2pro-localbus"; reg = <0xe0005000 0xd8>; - ranges = <0 0 0xff800000 0x800000>; + ranges = <0 0 0xff800000 0x800000 + 1 0 0x60000000 0x001000>; nor-flash@0,0 { compatible = "intel,PC28F640P30T85", "cfi-flash";
@@ -300,6 +302,19 @@ bank-width = <2>; device-width = <1>; }; + + nand-flash@1,0 { + compatible = "stmicro,NAND512W3A2BN6E", "fsl,upm-nand"; + reg = <1 0 1>; + width = <1>; + upm = "A"; + upm-addr-offset = <16>; + upm-cmd-offset = <8>; + gpios = <4 18>; + gpio-parent = <&qe_pio>; + wait-pattern; + wait-write; + }; }; pci0: pci@e0008500 {
arch/powerpc/platforms/83xx/Kconfig +1 -0
@@ -88,6 +88,7 @@ config PPC_MPC836x bool select PPC_UDBG_16550 select PPC_INDIRECT_PCI + select FSL_UPM default y if MPC836x_MDS || MPC836x_RDK config PPC_MPC837x
Signature · 1 line
1.5.2.2