USB: add support for CNS3XXX SOC's EHCI/OHCI controller
Subsystems (5)
cover USB: add support for CNS3XXX SOC's EHCI/OHCI controller
From: Mac Lin <[email protected]>
The first patch prepare the mach-cns3xxx power management code for drivers use. The other two patches add the bus glue for EHCI/OHCI controller in mach-cns3xxx and usb.
This patchset is based on linux-2.6.37-rc2
Mac Lin (3):
ARM: cns3xxx: Add new and export the old power management functions
ARM: cns3xxx: Add architecture definition for EHCI/OHCI controller
USB: cns3xxx: Add EHCI and OHCI bus glue for CNS3XXX SOCs
arch/arm/mach-cns3xxx/cns3420vb.c | 50 ++++++++ arch/arm/mach-cns3xxx/core.h | 4 +- arch/arm/mach-cns3xxx/include/mach/cns3xxx.h | 2 - arch/arm/mach-cns3xxx/include/mach/pm.h | 21 +++ arch/arm/mach-cns3xxx/pm.c | 21 +++ drivers/usb/Kconfig | 2 + drivers/usb/host/Kconfig | 15 +++ drivers/usb/host/ehci-cns3xxx.c | 176 ++++++++++++++++++++++++++ drivers/usb/host/ehci-hcd.c | 5 + drivers/usb/host/ohci-cns3xxx.c | 171 +++++++++++++++++++++++++ drivers/usb/host/ohci-hcd.c | 5 + 11 files changed, 468 insertions(+), 4 deletions(-) create mode 100644 arch/arm/mach-cns3xxx/include/mach/pm.h create mode 100644 drivers/usb/host/ehci-cns3xxx.c create mode 100644 drivers/usb/host/ohci-cns3xxx.c
PATCH 1/3 ARM: cns3xxx: Add new and export the old power management functions
From: Mac Lin <[email protected]>
This patch add cns3xxx_pwr_clk_dis, and export thoes power management functions that may be used by many other device drivers on CNS3XXX.
--- arch/arm/mach-cns3xxx/core.h | 4 ++-- arch/arm/mach-cns3xxx/include/mach/pm.h | 19 +++++++++++++++++++ arch/arm/mach-cns3xxx/pm.c | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 arch/arm/mach-cns3xxx/include/mach/pm.h
arch/arm/mach-cns3xxx/core.h +2 -2
@@ -11,13 +11,13 @@#ifndef __CNS3XXX_CORE_H#define __CNS3XXX_CORE_H +#include <mach/pm.h> +extern void __iomem *gic_cpu_base_addr;extern struct sys_timer cns3xxx_timer;void __init cns3xxx_map_io (void );void __init cns3xxx_init_irq (void );void cns3xxx_power_off (void ); -void cns3xxx_pwr_power_up (unsigned int block); -void cns3xxx_pwr_power_down (unsigned int block);#endif /* __CNS3XXX_CORE_H */
arch/arm/mach-cns3xxx/include/mach/pm.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Copyright 2000 Deep Blue Solutions Ltd +* Copyright 2004 ARM Limited +* Copyright 2008 Cavium Networks +* +* This file 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. +*/ + +#ifndef __CNS3XXX_PM_H +#define __CNS3XXX_PM_H + +void cns3xxx_pwr_clk_en (unsigned int block); +void cns3xxx_pwr_clk_dis (unsigned int block); +void cns3xxx_pwr_power_up (unsigned int block); +void cns3xxx_pwr_power_down (unsigned int block); + +#endif /* __CNS3XXX_PM_H */
arch/arm/mach-cns3xxx/pm.c +17 -0
@@ -6,6 +6,8 @@* published by the Free Software Foundation. */ +#include <linux/init.h> +#include <linux/module.h> #include <linux/io.h> #include <linux/delay.h> #include <mach/system.h>
@@ -18,6 +20,16 @@ void cns3xxx_pwr_clk_en(unsigned int block) reg |= (block &PM_CLK_GATE_REG_MASK );__raw_writel (reg,PM_CLK_GATE_REG ); } +EXPORT_SYMBOL (cns3xxx_pwr_clk_en); + +void cns3xxx_pwr_clk_dis (unsigned int block) +{ +u32 reg =__raw_readl (PM_CLK_GATE_REG ); + + reg &= ~(block &PM_CLK_GATE_REG_MASK ); +__raw_writel (reg,PM_CLK_GATE_REG ); +} +EXPORT_SYMBOL (cns3xxx_pwr_clk_dis);void cns3xxx_pwr_power_up (unsigned int block) {
@@ -29,6 +41,7 @@ void cns3xxx_pwr_power_up(unsigned int block)/* Wait for 300us for the PLL output clock locked. */ udelay (300 ); }; +EXPORT_SYMBOL (cns3xxx_pwr_power_up);void cns3xxx_pwr_power_down (unsigned int block) {
@@ -38,6 +51,7 @@ void cns3xxx_pwr_power_down(unsigned int block) reg |= (block &CNS3XXX_PWR_PLL_ALL );__raw_writel (reg,PM_PLL_HM_PD_CTRL_REG ); }; +EXPORT_SYMBOL (cns3xxx_pwr_power_down);static void cns3xxx_pwr_soft_rst_force (unsigned int block) {
@@ -56,6 +70,7 @@ static void cns3xxx_pwr_soft_rst_force(unsigned int block)__raw_writel (reg,PM_SOFT_RST_REG ); } +EXPORT_SYMBOL (cns3xxx_pwr_soft_rst_force);void cns3xxx_pwr_soft_rst (unsigned int block) {
@@ -69,6 +84,7 @@ void cns3xxx_pwr_soft_rst(unsigned int block) }cns3xxx_pwr_soft_rst_force (block); } +EXPORT_SYMBOL (cns3xxx_pwr_soft_rst);void arch_reset (char mode,const char *cmd) {
@@ -99,3 +115,4 @@ int cns3xxx_cpu_clock(void)return cpu; } +EXPORT_SYMBOL (cns3xxx_cpu_clock);
Signature · 1 line
1.7.3
PATCH 2/3 ARM: cns3xxx: Add architecture definition for EHCI/OHCI controller
In reply to mkl0301 at gmail.comFrom: Mac Lin <[email protected]>
This patch add plateform_device for EHCI and OHCI controller on CNS3XXX. Power reference count (usb_pwr_ref) is used to control enabling and disabling the single clock control for both EHCI and OHCI controller.
It also remove EHCI/OHCI unused virtual address definitions.
--- arch/arm/mach-cns3xxx/cns3420vb.c | 50 ++++++++++++++++++++++++++ arch/arm/mach-cns3xxx/include/mach/cns3xxx.h | 2 - arch/arm/mach-cns3xxx/include/mach/pm.h | 2 + arch/arm/mach-cns3xxx/pm.c | 4 ++ 4 files changed, 56 insertions(+), 2 deletions(-)
arch/arm/mach-cns3xxx/cns3420vb.c +50 -0
@@ -107,11 +107,61 @@ static void __init cns3420_early_serial_setup(void)#endif } +static struct resource cns3xxx_usb_ehci_resource[] = { + [0 ] = { + .start =CNS3XXX_USB_BASE , + .end =CNS3XXX_USB_BASE +SZ_16M -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =IRQ_CNS3XXX_USB_EHCI , + .flags =IORESOURCE_IRQ , + }, +}; + +static u64 cns3xxx_usb_dma_mask =0xffffffffULL ; + +static struct platform_device cns3xxx_usb_ehci_device = { + .name ="cns3xxx-ehci" , + .num_resources =ARRAY_SIZE (cns3xxx_usb_ehci_resource), + .resource = cns3xxx_usb_ehci_resource, + .dev = { + .dma_mask = &cns3xxx_usb_dma_mask, + .coherent_dma_mask =0xffffffffULL , + }, +}; + +static struct resource cns3xxx_usb_ohci_resource[] = { + [0 ] = { + .start =CNS3XXX_USB_OHCI_BASE , + .end =CNS3XXX_USB_OHCI_BASE +SZ_16M -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =IRQ_CNS3XXX_USB_OHCI , + .flags =IORESOURCE_IRQ , + }, +}; + +static u64 cns3xxx_usb_ohci_dma_mask =0xffffffffULL ; +static struct platform_device cns3xxx_usb_ohci_device = { + .name ="cns3xxx-ohci" , + .dev = { + .dma_mask = &cns3xxx_usb_ohci_dma_mask, + .coherent_dma_mask =0xffffffffULL , + }, + .num_resources =2 , + .resource = cns3xxx_usb_ohci_resource, +}; + +/* * Initialization */ static struct platform_device *cns3420_pdevs[]__initdata = { &cns3420_nor_pdev, + &cns3xxx_usb_ehci_device, + &cns3xxx_usb_ohci_device, };static void __init cns3420_init (void )
arch/arm/mach-cns3xxx/include/mach/cns3xxx.h +0 -2
@@ -165,7 +165,6 @@#define CNS3XXX_USBOTG_BASE_VIRT 0xFFF15000#define CNS3XXX_USB_BASE 0x82000000/* USB Host Control */ -#define CNS3XXX_USB_BASE_VIRT 0xFFF16000#define CNS3XXX_SATA2_BASE 0x83000000/* SATA */ #define CNS3XXX_SATA2_SIZE SZ_16M
@@ -184,7 +183,6 @@#define CNS3XXX_2DG_BASE_VIRT 0xFFF1B000#define CNS3XXX_USB_OHCI_BASE 0x88000000/* USB OHCI */ -#define CNS3XXX_USB_OHCI_BASE_VIRT 0xFFF1C000#define CNS3XXX_L2C_BASE 0x92000000/* L2 Cache Control */ #define CNS3XXX_L2C_BASE_VIRT 0xFFF27000
arch/arm/mach-cns3xxx/include/mach/pm.h +2 -0
@@ -16,4 +16,6 @@ void cns3xxx_pwr_clk_dis(unsigned int block);void cns3xxx_pwr_power_up (unsigned int block);void cns3xxx_pwr_power_down (unsigned int block); +extern atomic_t usb_pwr_ref; +#endif /* __CNS3XXX_PM_H */
arch/arm/mach-cns3xxx/pm.c +4 -0
@@ -10,6 +10,7 @@#include <linux/module.h> #include <linux/io.h> #include <linux/delay.h> +#include <asm/atomic.h> #include <mach/system.h> #include <mach/cns3xxx.h>
@@ -116,3 +117,6 @@ int cns3xxx_cpu_clock(void)return cpu; }EXPORT_SYMBOL (cns3xxx_cpu_clock); + +atomic_t usb_pwr_ref =ATOMIC_INIT (0 ); +EXPORT_SYMBOL (usb_pwr_ref);
Signature · 1 line
1.7.3
PATCH 3/3 USB: cns3xxx: Add EHCI and OHCI bus glue for CNS3XXX SOCs
In reply to mkl0301 at gmail.comFrom: Mac Lin <[email protected]>
The CNS3XXX SOC has include USB EHCI and OHCI compatible controllers. This patch adds the necessary glue logic to allow ehci-hcd and ohci-hcd drivers to work on CNS3XXX
The EHCI and OHCI controllers share a common clock control and reset bit, therefore additional check for the timming of enabling and disabling is required. The USB bit of PLL Power Down Control is also shared by OTG, 24MHz UART clock, Crypto clock, PCIe reference clock, and Clock Scale Generator. Therefore we only ensure it is enabled, while not disabling it.
--- drivers/usb/Kconfig | 2 + drivers/usb/host/Kconfig | 15 ++++ drivers/usb/host/ehci-cns3xxx.c | 176 +++++++++++++++++++++++++++++++++++++++ drivers/usb/host/ehci-hcd.c | 5 + drivers/usb/host/ohci-cns3xxx.c | 171 +++++++++++++++++++++++++++++++++++++ drivers/usb/host/ohci-hcd.c | 5 + 6 files changed, 374 insertions(+), 0 deletions(-) create mode 100644 drivers/usb/host/ehci-cns3xxx.c create mode 100644 drivers/usb/host/ohci-cns3xxx.c
drivers/usb/Kconfig +2 -0
@@ -41,6 +41,7 @@ config USB_ARCH_HAS_OHCI default y if MFD_TC6393XB default y if ARCH_W90X900 default y if ARCH_DAVINCI_DA8XX + default y if ARCH_CNS3XXX # PPC: default y if STB03xxx default y if PPC_MPC52xx
@@ -66,6 +67,7 @@ config USB_ARCH_HAS_EHCI default y if ARCH_AT91SAM9G45 default y if ARCH_MXC default y if ARCH_OMAP3 + default y if ARCH_CNS3XXX default PCI # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
drivers/usb/host/Kconfig +15 -0
@@ -147,6 +147,14 @@ config USB_W90X900_EHCI ---help--- Enables support for the W90X900 USB controller +config USB_CNS3XXX_EHCI + bool "Cavium CNS3XXX EHCI Module" + depends on USB_EHCI_HCD && ARCH_CNS3XXX + ---help--- + Enable support for the CNS3XXX SOC's on-chip EHCI controller. + It is needed for high-speed (480Mbit/sec) USB 2.0 device + support. + config USB_OXU210HP_HCD tristate "OXU210HP HCD support" depends on USB
@@ -286,6 +294,13 @@ config USB_OHCI_HCD_SSB If unsure, say N. +config USB_CNS3XXX_OHCI + bool "Cavium CNS3XXX OHCI Module" + depends on USB_OHCI_HCD && ARCH_CNS3XXX + ---help--- + Enable support for the CNS3XXX SOC's on-chip OHCI controller. + It is needed for low-speed USB 1.0 device support. + config USB_OHCI_BIG_ENDIAN_DESC bool depends on USB_OHCI_HCD
drivers/usb/host/ehci-cns3xxx.c new file +176 -0
176 lines not on this page · raw message
drivers/usb/host/ehci-hcd.c +5 -0
@@ -1216,6 +1216,11 @@ MODULE_LICENSE ("GPL");#define PLATFORM_DRIVER ehci_octeon_driver#endif +#ifdef CONFIG_USB_CNS3XXX_EHCI +#include "ehci-cns3xxx.c" +#define PLATFORM_DRIVER cns3xxx_ehci_driver +#endif +#if !defined(PCI_DRIVER ) && !defined(PLATFORM_DRIVER ) && \ !defined(PS3_SYSTEM_BUS_DRIVER ) && !defined(OF_PLATFORM_DRIVER ) && \ !defined(XILINX_OF_PLATFORM_DRIVER )
drivers/usb/host/ohci-cns3xxx.c new file +171 -0
171 lines not on this page · raw message
drivers/usb/host/ohci-hcd.c +5 -0
@@ -1111,6 +1111,11 @@ MODULE_LICENSE ("GPL");#define PLATFORM_DRIVER ohci_octeon_driver#endif +#ifdef CONFIG_USB_CNS3XXX_OHCI +#include "ohci-cns3xxx.c" +#define PLATFORM_DRIVER ohci_hcd_cns3xxx_driver +#endif + #if !defined(PCI_DRIVER) && \ !defined(PLATFORM_DRIVER) && \ !defined(OMAP1_PLATFORM_DRIVER) && \
Signature · 1 line
1.7.3