AMBA Bus support
Subsystems (7)
v2 cover AMBA Bus support
Hi,
v2: upadte comment
this first patch series add the AMBA Bus support and is a preperation for the adding of the ST-E ux500 support
please pull
The following changes since commit 298d15571da8d1cb71e7fd87cc53cad3b2bf1d12:
i.MX51: unbreak FEC iomux (2012-09-07 10:28:17 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git tags/amba_bus
for you to fetch changes up to 75a0136ccae3899aee91f1d8d38274c426f99175:
amba-pl011: add st specific init (2012-09-11 12:48:34 +0800)
----------------------------------------------------------------
arm: Introduce ARM AMBA bus
This allow to detect the amba device and use the right driver for it at runtime.
With pl011 amba support (ARM & ST Variant)
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
Introduce ARM AMBA bus
amba-pl011: switch to amba bus
amba-pl011: add st specific init
arch/arm/mach-nomadik/8815.c | 9 +++---- arch/arm/mach-versatile/core.c | 7 ++++-- drivers/Makefile | 1 + drivers/amba/Makefile | 2 ++ drivers/amba/bus.c | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/serial/amba-pl011.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++---------- include/linux/amba/bus.h | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/amba/serial.h | 29 +++++++++++++++++++++++ 8 files changed, 467 insertions(+), 18 deletions(-) create mode 100644 drivers/amba/Makefile create mode 100644 drivers/amba/bus.c create mode 100644 include/linux/amba/bus.h
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 2/3 amba-pl011: switch to amba bus
In reply to Jean-Christophe PLAGNIOL-VILLARDswitch as the same time the nomadik and versatile arch that use the driver.
--- arch/arm/mach-nomadik/8815.c | 9 +++++---- arch/arm/mach-versatile/core.c | 7 +++++-- drivers/serial/amba-pl011.c | 34 ++++++++++++++++++++++++---------- 3 files changed, 34 insertions(+), 16 deletions(-)
arch/arm/mach-nomadik/8815.c +5 -4
@@ -25,6 +25,7 @@#include <mach/hardware.h> #include <asm/armlinux.h> #include <generated/mach-types.h> +#include <linux/amba/bus.h> #include "clock.h"
@@ -32,12 +33,15 @@ static struct clk st8815_clk_48 = { .rate = 48 * 1000 * 1000, }; +static struct clk st8815_dummy; +void st8815_add_device_sdram (u32 size) {arm_add_mem_device ("ram0" ,0x00000000 , size); }static struct clk_lookup clocks_lookups[] = { +CLKDEV_CON_ID ("apb_pclk" , &st8815_dummy),CLKDEV_DEV_ID ("uart-pl0110" , &st8815_clk_48),CLKDEV_DEV_ID ("uart-pl0111" , &st8815_clk_48), };
@@ -53,7 +57,6 @@ postcore_initcall(st8815_clkdev_init);void st8815_register_uart (unsigned id) {resource_size_t start; -struct device_d *dev;switch (id) {case 0 :
@@ -63,7 +66,5 @@ void st8815_register_uart(unsigned id) start =NOMADIK_UART1_BASE ;break ; } - dev =add_generic_device ("uart-pl011" , id,NULL , start,4096 , -IORESOURCE_MEM ,NULL ); -nmdk_clk_create (&st8815_clk_48,dev_name (dev)); +amba_apb_device_add (NULL ,"uart-pl011" , id, start,4096 ,NULL ,0 ); }
arch/arm/mach-versatile/core.c +5 -2
@@ -34,6 +34,7 @@#include <linux/clkdev.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/amba/bus.h> #include <io.h> #include <asm/hardware/arm_timer.h>
@@ -51,6 +52,8 @@ struct clk {unsigned long rate; }; +static struct clk ref_clk_dummy; +static struct clk ref_clk_24 = { .rate =24000000 , };
@@ -145,6 +148,7 @@ static int vpb_clocksource_init(void)core_initcall (vpb_clocksource_init);static struct clk_lookup clocks_lookups[] = { +CLKDEV_CON_ID ("apb_pclk" , &ref_clk_dummy),CLKDEV_DEV_ID ("uart-pl0110" , &ref_clk_24),CLKDEV_DEV_ID ("uart-pl0111" , &ref_clk_24),CLKDEV_DEV_ID ("uart-pl0112" , &ref_clk_24),
@@ -179,8 +183,7 @@ void versatile_register_uart(unsigned id)default :return ; } -add_generic_device ("uart-pl011" , id,NULL , start,4096 , -IORESOURCE_MEM ,NULL ); +amba_apb_device_add (NULL ,"uart-pl011" , id, start,4096 ,NULL ,0 ); }void __noreturn reset_cpu (unsigned long ignored)
drivers/serial/amba-pl011.c +24 -10
@@ -35,6 +35,7 @@#include <linux/amba/serial.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/amba/bus.h> /* * We wrap our port structure around the generic console_device.
@@ -118,11 +119,8 @@ static int pl011_tstc(struct console_device *cdev)int pl011_init_port (struct console_device *cdev) { -struct device_d *dev = cdev->dev;struct amba_uart_port *uart =to_amba_uart_port (cdev); - uart->base =dev_request_mem_region (dev,0 ); -/* ** First, disable everything. */
@@ -154,19 +152,20 @@ int pl011_init_port (struct console_device *cdev)return 0 ; } -static int pl011_probe (struct device_d *dev) +static int pl011_probe (struct amba_device *dev,const struct amba_id *id) {struct amba_uart_port *uart;struct console_device *cdev; uart =xzalloc (sizeof (struct amba_uart_port )); - uart->clk =clk_get (dev,NULL ); + uart->clk =clk_get (&dev->dev,NULL ); + uart->base =amba_get_mem_region (dev);if (IS_ERR (uart->clk))return PTR_ERR (uart->clk); cdev = &uart->uart; - cdev->dev = dev; + cdev->dev = &dev->dev; cdev->f_caps =CONSOLE_STDIN |CONSOLE_STDOUT |CONSOLE_STDERR ; cdev->tstc = pl011_tstc; cdev->putc = pl011_putc;
@@ -182,14 +181,29 @@ static int pl011_probe(struct device_d *dev)return 0 ; } -static struct driver_d pl011_driver = { - .name ="uart-pl011" , - .probe = pl011_probe, +static struct amba_id pl011_ids[] = { + { + .id =0x00041011 , + .mask =0x000fffff , + }, + { + .id =0x00380802 , + .mask =0x00ffffff , + }, + {0 ,0 }, +}; + +struct amba_driver pl011_driver = { + .drv = { + .name ="uart-pl011" , + }, + .probe = pl011_probe, + .id_table = pl011_ids, };static int pl011_init (void ) { -register_driver (&pl011_driver); +amba_driver_register (&pl011_driver);return 0 ; }
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 3/3 amba-pl011: add st specific init
In reply to Jean-Christophe PLAGNIOL-VILLARDThis is need on the new IP for ux500
--- drivers/serial/amba-pl011.c | 40 ++++++++++++++++++++++++++++++++++++++-- include/linux/amba/serial.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-)
drivers/serial/amba-pl011.c +38 -2
@@ -45,6 +45,23 @@ struct amba_uart_port {struct console_device uart;/* uart */ struct clk *clk;/* uart clock */ u32 uartclk; +struct vendor_data *vendor; +}; + +/* There is by now at least one vendor with differing details, so handle it */ +struct vendor_data { +unsigned int lcrh_tx; +unsigned int lcrh_rx; +}; + +static struct vendor_data vendor_arm = { + .lcrh_tx =UART011_LCRH , + .lcrh_rx =UART011_LCRH , +}; + +static struct vendor_data vendor_st = { + .lcrh_tx =ST_UART011_LCRH_TX , + .lcrh_rx =ST_UART011_LCRH_RX , }; static inline struct amba_uart_port *
@@ -117,6 +134,23 @@ static int pl011_tstc(struct console_device *cdev)return !(readl (uart->base + UART01x_FR) & UART01x_FR_RXFE); } +static void pl011_rlcr (struct amba_uart_port *uart,u32 lcr) +{ +struct vendor_data *vendor = uart->vendor; + +writew (lcr, uart->base + vendor->lcrh_rx); +if (vendor->lcrh_tx != vendor->lcrh_rx) { +int i; +/* +* Wait 10 PCLKs before writing LCRH_TX register, +* to get this delay write read only register 10 times +*/ +for (i =0 ; i <10 ; ++i) +writew (0xff , uart->base +UART011_MIS ); +writew (lcr, uart->base + vendor->lcrh_tx); + } +} +int pl011_init_port (struct console_device *cdev) {struct amba_uart_port *uart =to_amba_uart_port (cdev);
@@ -140,8 +174,7 @@ int pl011_init_port (struct console_device *cdev)/* ** Set the UART to be 8 bits, 1 stop bit, no parity, fifo enabled. */ -writel ((UART01x_LCRH_WLEN_8 | UART01x_LCRH_FEN), - uart->base +UART011_LCRH ); +pl011_rlcr (uart, UART01x_LCRH_WLEN_8 | UART01x_LCRH_FEN);/* ** Finally, enable the UART
@@ -160,6 +193,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) uart =xzalloc (sizeof (struct amba_uart_port )); uart->clk =clk_get (&dev->dev,NULL ); uart->base =amba_get_mem_region (dev); + uart->vendor = (void *)id->data;if (IS_ERR (uart->clk))return PTR_ERR (uart->clk);
@@ -185,10 +219,12 @@ static struct amba_id pl011_ids[] = { { .id = 0x00041011, .mask = 0x000fffff, + .data = &vendor_arm, }, { .id = 0x00380802, .mask = 0x00ffffff, + .data = &vendor_st, }, { 0, 0 }, };
include/linux/amba/serial.h +29 -0
@@ -32,16 +32,20 @@#define UART01x_RSR 0x04/* Receive status register (Read). */ #define UART01x_ECR 0x04/* Error clear register (Write). */ #define UART010_LCRH 0x08/* Line control register, high byte. */ +#define ST_UART011_DMAWM 0x08/* DMA watermark configure register. */ #define UART010_LCRM 0x0C/* Line control register, middle byte. */ +#define ST_UART011_TIMEOUT 0x0C/* Timeout period register. */ #define UART010_LCRL 0x10/* Line control register, low byte. */ #define UART010_CR 0x14/* Control register. */ #define UART01x_FR 0x18/* Flag register (Read only). */ #define UART010_IIR 0x1C/* Interrupt indentification register (Read). */ #define UART010_ICR 0x1C/* Interrupt clear register (Write). */ +#define ST_UART011_LCRH_RX 0x1C/* Rx line control register. */ #define UART01x_ILPR 0x20/* IrDA low power counter register. */ #define UART011_IBRD 0x24/* Integer baud rate divisor register. */ #define UART011_FBRD 0x28/* Fractional baud rate divisor register. */ #define UART011_LCRH 0x2c/* Line control register. */ +#define ST_UART011_LCRH_TX 0x2c/* Tx Line control register. */ #define UART011_CR 0x30/* Control register. */ #define UART011_IFLS 0x34/* Interrupt fifo level select. */ #define UART011_IMSC 0x38/* Interrupt mask. */
@@ -49,6 +53,15 @@#define UART011_MIS 0x40/* Masked interrupt status. */ #define UART011_ICR 0x44/* Interrupt clear register. */ #define UART011_DMACR 0x48/* DMA control register. */ +#define ST_UART011_XFCR 0x50/* XON/XOFF control register. */ +#define ST_UART011_XON1 0x54/* XON1 register. */ +#define ST_UART011_XON2 0x58/* XON2 register. */ +#define ST_UART011_XOFF1 0x5C/* XON1 register. */ +#define ST_UART011_XOFF2 0x60/* XON2 register. */ +#define ST_UART011_ITCR 0x80/* Integration test control register. */ +#define ST_UART011_ITIP 0x84/* Integration test input register. */ +#define ST_UART011_ABCR 0x100/* Autobaud control register. */ +#define ST_UART011_ABIMSC 0x15C/* Autobaud interrupt mask/clear register. */ #define UART011_DR_OE (1 << 11)#define UART011_DR_BE (1 << 10)
@@ -84,6 +97,7 @@#define UART010_CR_TIE 0x0020#define UART010_CR_RIE 0x0010#define UART010_CR_MSIE 0x0008 +#define ST_UART011_CR_OVSFACT 0x0008/* Oversampling factor */ #define UART01x_CR_IIRLP 0x0004/* SIR low power mode */ #define UART01x_CR_SIREN 0x0002/* SIR enable */ #define UART01x_CR_UARTEN 0x0001/* UART enable */
@@ -99,6 +113,21 @@#define UART01x_LCRH_PEN 0x02#define UART01x_LCRH_BRK 0x01 +#define ST_UART011_DMAWM_RX_1 (0 << 3) +#define ST_UART011_DMAWM_RX_2 (1 << 3) +#define ST_UART011_DMAWM_RX_4 (2 << 3) +#define ST_UART011_DMAWM_RX_8 (3 << 3) +#define ST_UART011_DMAWM_RX_16 (4 << 3) +#define ST_UART011_DMAWM_RX_32 (5 << 3) +#define ST_UART011_DMAWM_RX_48 (6 << 3) +#define ST_UART011_DMAWM_TX_1 0 +#define ST_UART011_DMAWM_TX_2 1 +#define ST_UART011_DMAWM_TX_4 2 +#define ST_UART011_DMAWM_TX_8 3 +#define ST_UART011_DMAWM_TX_16 4 +#define ST_UART011_DMAWM_TX_32 5 +#define ST_UART011_DMAWM_TX_48 6 +#define UART010_IIR_RTIS 0x08#define UART010_IIR_TIS 0x04#define UART010_IIR_RIS 0x02
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/3 Introduce ARM AMBA bus
In reply to Jean-Christophe PLAGNIOL-VILLARDThis will allow to detect the amba device and use the right driver for it at runtime.
The code is base on linux 3.5.
--- drivers/Makefile | 1 + drivers/amba/Makefile | 2 + drivers/amba/bus.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/amba/bus.h | 153 +++++++++++++++++++++++++++++++++ 4 files changed, 366 insertions(+) create mode 100644 drivers/amba/Makefile create mode 100644 drivers/amba/bus.c create mode 100644 include/linux/amba/bus.h
drivers/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-y += base/ +obj-$(CONFIG_ARM_AMBA) += amba/ obj-y += net/ obj-y += serial/ obj-y += mtd/
drivers/amba/Makefile new file +2 -0
@@ -0,0 +1,2 @@ + +obj-y += bus.o
drivers/amba/bus.c new file +210 -0
210 lines not on this page · raw message
include/linux/amba/bus.h new file +153 -0
153 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
v2: upadte comment
this first patch series add the AMBA Bus support and is a preperation for the adding of the ST-E ux500 support
Quoted 8 lines
please pull
The following changes since commit298d15571da8d1cb71e7fd87cc53cad3b2bf1d12:i.MX51: unbreak FEC iomux (2012-09-07 10:28:17 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.gittags/amba_bus
Pulled, thanks
Sascha
Quoted 42 lines
for you to fetch changes up to
75a0136ccae3899aee91f1d8d38274c426f99175:amba-pl011: add st specific init (2012-09-11 12:48:34 +0800)
----------------------------------------------------------------
arm: Introduce ARM AMBA busThis allow to detect the amba device and use the right driver for it at runtime.
With pl011 amba support (ARM & ST Variant)
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
Introduce ARM AMBA bus
amba-pl011: switch to amba bus
amba-pl011: add st specific initarch/arm/mach-nomadik/8815.c | 9 +++---- arch/arm/mach-versatile/core.c | 7 ++++-- drivers/Makefile | 1 + drivers/amba/Makefile | 2 ++ drivers/amba/bus.c | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/serial/amba-pl011.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++---------- include/linux/amba/bus.h | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/amba/serial.h | 29 +++++++++++++++++++++++ 8 files changed, 467 insertions(+), 18 deletions(-) create mode 100644 drivers/amba/Makefile create mode 100644 drivers/amba/bus.c create mode 100644 include/linux/amba/bus.hBest Regards,
J._______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox