This is the second round of patches for mach-lpc32xx, for v3.6. It builds upon
the first round of 22 patches and includes clock updates that separate out
initialization from the board specific init to clock.c.
Further, a defconfig update for LPC32xx, dts file update and mmc bugfix is
included.
Signed-off-by: Roland Stigge <[email protected]>
--
You can also pull from
git://git.antcom.de/linux-2.6.git lpc32xx-next2
Roland Stigge (6):
ARM: LPC32xx: Init MMC via clock
ARM: LPC32xx: Add further bits to MMC init
ARM: LPC32xx: Remove wrong re-initialization of MMC clock register
ARM: LPC32xx: Update DTS file for EA3250 board
ARM: LPC32xx: Defconfig update
ARM: LPC32xx: Remove USB and I2C init from phy3250.c
Alexandre Pereira da Silva (1):
ARM: LPC32xx: Cleanup USB clock init
arch/arm/boot/dts/ea3250.dts | 17 ++++
arch/arm/configs/lpc32xx_defconfig | 2
arch/arm/mach-lpc32xx/clock.c | 90 ++++++++++++++++++++++----
arch/arm/mach-lpc32xx/include/mach/platform.h | 14 ++++
arch/arm/mach-lpc32xx/phy3250.c | 17 ----
5 files changed, 112 insertions(+), 28 deletions(-)
This patch fixes a bug, (wrongfully) resetting the value of
LPC32XX_CLKPWR_MS_CTRL back to its initial contents (after careful setup). This
was discovered only with a board/bootloader combination (EA3250) where the
contents of the respective register wasn't already at the correct value on
Linux boot.
Signed-off-by: Roland Stigge <[email protected]>
Acked-by: Alexandre Pereira da Silva <[email protected]>
---
arch/arm/mach-lpc32xx/clock.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
--- linux-2.6.orig/arch/arm/mach-lpc32xx/clock.c
+++ linux-2.6/arch/arm/mach-lpc32xx/clock.c
@@ -871,7 +871,7 @@ static unsigned long mmc_round_rate(stru
static int mmc_set_rate(struct clk *clk, unsigned long rate)
{
- u32 oldclk, tmp;
+ u32 tmp;
unsigned long prate, div, crate = mmc_round_rate(clk, rate);
prate = clk->parent->get_rate(clk->parent);
@@ -879,16 +879,12 @@ static int mmc_set_rate(struct clk *clk,
div = prate / crate;
/* The MMC clock must be on when accessing an MMC register */
- oldclk = __raw_readl(LPC32XX_CLKPWR_MS_CTRL);
- __raw_writel(oldclk | LPC32XX_CLKPWR_MSCARD_SDCARD_EN,
- LPC32XX_CLKPWR_MS_CTRL);
tmp = __raw_readl(LPC32XX_CLKPWR_MS_CTRL) &
~LPC32XX_CLKPWR_MSCARD_SDCARD_DIV(0xf);
- tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_DIV(div);
+ tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_DIV(div) |
+ LPC32XX_CLKPWR_MSCARD_SDCARD_EN;
__raw_writel(tmp, LPC32XX_CLKPWR_MS_CTRL);
- __raw_writel(oldclk, LPC32XX_CLKPWR_MS_CTRL);
-
return 0;
}
This patch makes sure certain MMC bits are cleared as they should for
initialization.
Signed-off-by: Roland Stigge <[email protected]>
Acked-by: Alexandre Pereira da Silva <[email protected]>
---
arch/arm/mach-lpc32xx/clock.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--- linux-2.6.orig/arch/arm/mach-lpc32xx/clock.c
+++ linux-2.6/arch/arm/mach-lpc32xx/clock.c
@@ -813,7 +813,11 @@ static int mmc_onoff_enable(struct clk *
tmp = __raw_readl(LPC32XX_CLKPWR_MS_CTRL) &
~(LPC32XX_CLKPWR_MSCARD_SDCARD_EN |
- LPC32XX_CLKPWR_MSCARD_MSDIO_PU_EN);
+ LPC32XX_CLKPWR_MSCARD_MSDIO_PU_EN |
+ LPC32XX_CLKPWR_MSCARD_MSDIO_PIN_DIS |
+ LPC32XX_CLKPWR_MSCARD_MSDIO0_DIS |
+ LPC32XX_CLKPWR_MSCARD_MSDIO1_DIS |
+ LPC32XX_CLKPWR_MSCARD_MSDIO23_DIS);
/* If rate is 0, disable clock */
if (enable != 0)
This patch moves MMC/SD controller initialization from the board specific file
phy3250.c to clock.c.
Signed-off-by: Roland Stigge <[email protected]>
Acked-by: Alexandre Pereira da Silva <[email protected]>
---
arch/arm/mach-lpc32xx/clock.c | 6 ++++--
arch/arm/mach-lpc32xx/phy3250.c | 5 -----
2 files changed, 4 insertions(+), 7 deletions(-)
--- linux-2.6.orig/arch/arm/mach-lpc32xx/clock.c
+++ linux-2.6/arch/arm/mach-lpc32xx/clock.c
@@ -812,11 +812,13 @@ static int mmc_onoff_enable(struct clk *
u32 tmp;
tmp = __raw_readl(LPC32XX_CLKPWR_MS_CTRL) &
- ~LPC32XX_CLKPWR_MSCARD_SDCARD_EN;
+ ~(LPC32XX_CLKPWR_MSCARD_SDCARD_EN |
+ LPC32XX_CLKPWR_MSCARD_MSDIO_PU_EN);
/* If rate is 0, disable clock */
if (enable != 0)
- tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_EN;
+ tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_EN |
+ LPC32XX_CLKPWR_MSCARD_MSDIO_PU_EN;
__raw_writel(tmp, LPC32XX_CLKPWR_MS_CTRL);
--- linux-2.6.orig/arch/arm/mach-lpc32xx/phy3250.c
+++ linux-2.6/arch/arm/mach-lpc32xx/phy3250.c
@@ -262,11 +262,6 @@ static void __init lpc3250_machine_init(
lpc32xx_serial_init();
- tmp = __raw_readl(LPC32XX_CLKPWR_MS_CTRL);
- tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_EN |
- LPC32XX_CLKPWR_MSCARD_MSDIO_PU_EN;
- __raw_writel(tmp, LPC32XX_CLKPWR_MS_CTRL);
-
/* Test clock needed for UDA1380 initial init */
__raw_writel(LPC32XX_CLKPWR_TESTCLK2_SEL_MOSC |
LPC32XX_CLKPWR_TESTCLK_TESTCLK2_EN,
This DTS file update adds:
* 3-channel ADC (for AD-IN on AD2, or 3-axis-accelerometer)
* Interrupt key
Signed-off-by: Roland Stigge <[email protected]>
---
arch/arm/boot/dts/ea3250.dts | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
--- linux-2.6.orig/arch/arm/boot/dts/ea3250.dts
+++ linux-2.6/arch/arm/boot/dts/ea3250.dts
@@ -152,6 +152,23 @@
uart1: serial@40014000 {
status = "okay";
};
+
+ /* 3-axis accelerometer X,Y,Z (or AD-IN instead of Z) */
+ adc@40048000 {
+ status = "okay";
+ };
+ };
+ };
+
+ gpio_keys {
+ compatible = "gpio-keys";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ autorepeat;
+ button@21 {
+ label = "GPIO Key UP";
+ linux,code = <103>;
+ gpios = <&gpio 4 1 0>; /* GPI_P3 1 */
};
};
};
USB and I2C initialization can be removed safely from the board specific
phy3250.c, now that initialization moved to the generalized clock.c.
Signed-off-by: Roland Stigge <[email protected]>
Tested-by: Alexandre Pereira da Silva <[email protected]>
---
arch/arm/mach-lpc32xx/phy3250.c | 12 ------------
1 file changed, 12 deletions(-)
--- linux-2.6.orig/arch/arm/mach-lpc32xx/phy3250.c
+++ linux-2.6/arch/arm/mach-lpc32xx/phy3250.c
@@ -248,18 +248,6 @@ static void __init lpc3250_machine_init(
tmp |= LPC32XX_CLKPWR_LCDCTRL_LCDTYPE_TFT16;
__raw_writel(tmp, LPC32XX_CLKPWR_LCDCLK_CTRL);
- /* Set up USB power */
- tmp = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
- tmp |= LPC32XX_CLKPWR_USBCTRL_HCLK_EN |
- LPC32XX_CLKPWR_USBCTRL_USBI2C_EN;
- __raw_writel(tmp, LPC32XX_CLKPWR_USB_CTRL);
-
- /* Set up I2C pull levels */
- tmp = __raw_readl(LPC32XX_CLKPWR_I2C_CLK_CTRL);
- tmp |= LPC32XX_CLKPWR_I2CCLK_USBI2CHI_DRIVE |
- LPC32XX_CLKPWR_I2CCLK_I2C2HI_DRIVE;
- __raw_writel(tmp, LPC32XX_CLKPWR_I2C_CLK_CTRL);
-
lpc32xx_serial_init();
/* Test clock needed for UDA1380 initial init */
This defconfig update for LPC32xx adds interrupt and polled gpio keyboard
drivers.
Signed-off-by: Roland Stigge <[email protected]>
---
arch/arm/configs/lpc32xx_defconfig | 2 ++
1 file changed, 2 insertions(+)
--- linux-2.6.orig/arch/arm/configs/lpc32xx_defconfig
+++ linux-2.6/arch/arm/configs/lpc32xx_defconfig
@@ -18,6 +18,7 @@ CONFIG_MODULE_UNLOAD=y
# CONFIG_BLK_DEV_BSG is not set
CONFIG_PARTITION_ADVANCED=y
CONFIG_ARCH_LPC32XX=y
+CONFIG_KEYBOARD_GPIO_POLLED=y
CONFIG_PREEMPT=y
CONFIG_AEABI=y
CONFIG_ZBOOT_ROM_TEXT=0x0
@@ -89,6 +90,7 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_X=240
CONFIG_INPUT_MOUSEDEV_SCREEN_Y=320
CONFIG_INPUT_EVDEV=y
# CONFIG_KEYBOARD_ATKBD is not set
+CONFIG_KEYBOARD_GPIO=y
CONFIG_KEYBOARD_LPC32XX=y
# CONFIG_INPUT_MOUSE is not set
CONFIG_INPUT_TOUCHSCREEN=y
From: Alexandre Pereira da Silva <[email protected]>
Move most of usb clock initialization from lpc32xx_udc and ohci-nxp to
clock.c. Also adds ohci clocks and otg clocks.
Signed-off-by: Alexandre Pereira da Silva <[email protected]>
Signed-off-by: Roland Stigge <[email protected]>
---
arch/arm/mach-lpc32xx/clock.c | 68 +++++++++++++++++++++++++-
arch/arm/mach-lpc32xx/include/mach/platform.h | 14 +++++
2 files changed, 81 insertions(+), 1 deletion(-)
--- linux-2.6.orig/arch/arm/mach-lpc32xx/clock.c
+++ linux-2.6/arch/arm/mach-lpc32xx/clock.c
@@ -739,14 +739,77 @@ static struct clk clk_rtc = {
.get_rate = local_return_parent_rate,
};
+static int local_usb_enable(struct clk *clk, int enable)
+{
+ u32 tmp;
+
+ if (enable) {
+ /* Set up I2C pull levels */
+ tmp = __raw_readl(LPC32XX_CLKPWR_I2C_CLK_CTRL);
+ tmp |= LPC32XX_CLKPWR_I2CCLK_USBI2CHI_DRIVE;
+ __raw_writel(tmp, LPC32XX_CLKPWR_I2C_CLK_CTRL);
+ }
+
+ return local_onoff_enable(clk, enable);
+}
+
static struct clk clk_usbd = {
.parent = &clk_usbpll,
- .enable = local_onoff_enable,
+ .enable = local_usb_enable,
.enable_reg = LPC32XX_CLKPWR_USB_CTRL,
.enable_mask = LPC32XX_CLKPWR_USBCTRL_HCLK_EN,
.get_rate = local_return_parent_rate,
};
+#define OTG_ALWAYS_MASK (LPC32XX_USB_OTG_OTG_CLOCK_ON | \
+ LPC32XX_USB_OTG_I2C_CLOCK_ON)
+
+static int local_usb_otg_enable(struct clk *clk, int enable)
+{
+ int to = 1000;
+
+ if (enable) {
+ __raw_writel(clk->enable_mask, clk->enable_reg);
+
+ while (((__raw_readl(LPC32XX_USB_OTG_CLK_STAT) &
+ clk->enable_mask) != clk->enable_mask) && (to > 0))
+ to--;
+ } else {
+ __raw_writel(OTG_ALWAYS_MASK, clk->enable_reg);
+
+ while (((__raw_readl(LPC32XX_USB_OTG_CLK_STAT) &
+ OTG_ALWAYS_MASK) != OTG_ALWAYS_MASK) && (to > 0))
+ to--;
+ }
+
+ if (to)
+ return 0;
+ else
+ return -1;
+}
+
+static struct clk clk_usb_otg_dev = {
+ .parent = &clk_usbpll,
+ .enable = local_usb_otg_enable,
+ .enable_reg = LPC32XX_USB_OTG_CLK_CTRL,
+ .enable_mask = LPC32XX_USB_OTG_AHB_M_CLOCK_ON |
+ LPC32XX_USB_OTG_OTG_CLOCK_ON |
+ LPC32XX_USB_OTG_DEV_CLOCK_ON |
+ LPC32XX_USB_OTG_I2C_CLOCK_ON,
+ .get_rate = local_return_parent_rate,
+};
+
+static struct clk clk_usb_otg_host = {
+ .parent = &clk_usbpll,
+ .enable = local_usb_otg_enable,
+ .enable_reg = LPC32XX_USB_OTG_CLK_CTRL,
+ .enable_mask = LPC32XX_USB_OTG_AHB_M_CLOCK_ON |
+ LPC32XX_USB_OTG_OTG_CLOCK_ON |
+ LPC32XX_USB_OTG_HOST_CLOCK_ON |
+ LPC32XX_USB_OTG_I2C_CLOCK_ON,
+ .get_rate = local_return_parent_rate,
+};
+
static int tsc_onoff_enable(struct clk *clk, int enable)
{
u32 tmp;
@@ -1145,6 +1208,9 @@ static struct clk_lookup lookups[] = {
CLKDEV_INIT("31060000.ethernet", NULL, &clk_net),
CLKDEV_INIT("dev:clcd", NULL, &clk_lcd),
CLKDEV_INIT("31020000.usbd", "ck_usbd", &clk_usbd),
+ CLKDEV_INIT("31020000.ohci", "ck_usbd", &clk_usbd),
+ CLKDEV_INIT("31020000.usbd", "ck_usb_otg", &clk_usb_otg_dev),
+ CLKDEV_INIT("31020000.ohci", "ck_usb_otg", &clk_usb_otg_host),
CLKDEV_INIT("lpc32xx_rtc", NULL, &clk_rtc),
};
--- linux-2.6.orig/arch/arm/mach-lpc32xx/include/mach/platform.h
+++ linux-2.6/arch/arm/mach-lpc32xx/include/mach/platform.h
@@ -694,4 +694,18 @@
#define LPC32XX_GPIO_P2_MUX_CLR _GPREG(0x02C)
#define LPC32XX_GPIO_P2_MUX_STATE _GPREG(0x030)
+/*
+ * USB Otg Registers
+ */
+#define _OTGREG(x) io_p2v(LPC32XX_USB_OTG_BASE + (x))
+#define LPC32XX_USB_OTG_CLK_CTRL _OTGREG(0xFF4)
+#define LPC32XX_USB_OTG_CLK_STAT _OTGREG(0xFF8)
+
+/* USB OTG CLK CTRL bit defines */
+#define LPC32XX_USB_OTG_AHB_M_CLOCK_ON _BIT(4)
+#define LPC32XX_USB_OTG_OTG_CLOCK_ON _BIT(3)
+#define LPC32XX_USB_OTG_I2C_CLOCK_ON _BIT(2)
+#define LPC32XX_USB_OTG_DEV_CLOCK_ON _BIT(1)
+#define LPC32XX_USB_OTG_HOST_CLOCK_ON _BIT(0)
+
#endif
On Sun, Jun 24, 2012 at 10:47 AM, Roland Stigge <[email protected]> wrote:
> This DTS file update adds:
> * 3-channel ADC (for AD-IN on AD2, or 3-axis-accelerometer)
> * Interrupt key
>
> Signed-off-by: Roland Stigge <[email protected]>
Acked-by: Alexandre Pereira da Silva <[email protected]>
> ---
> ?arch/arm/boot/dts/ea3250.dts | ? 17 +++++++++++++++++
> ?1 file changed, 17 insertions(+)
>
> --- linux-2.6.orig/arch/arm/boot/dts/ea3250.dts
> +++ linux-2.6/arch/arm/boot/dts/ea3250.dts
> @@ -152,6 +152,23 @@
> ? ? ? ? ? ? ? ? ? ? ? ?uart1: serial@40014000 {
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?status = "okay";
> ? ? ? ? ? ? ? ? ? ? ? ?};
> +
> + ? ? ? ? ? ? ? ? ? ? ? /* 3-axis accelerometer X,Y,Z (or AD-IN instead of Z) */
> + ? ? ? ? ? ? ? ? ? ? ? adc@40048000 {
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? status = "okay";
> + ? ? ? ? ? ? ? ? ? ? ? };
> + ? ? ? ? ? ? ? };
> + ? ? ? };
> +
> + ? ? ? gpio_keys {
> + ? ? ? ? ? ? ? compatible = "gpio-keys";
> + ? ? ? ? ? ? ? #address-cells = <1>;
> + ? ? ? ? ? ? ? #size-cells = <0>;
> + ? ? ? ? ? ? ? autorepeat;
> + ? ? ? ? ? ? ? button@21 {
> + ? ? ? ? ? ? ? ? ? ? ? label = "GPIO Key UP";
> + ? ? ? ? ? ? ? ? ? ? ? linux,code = <103>;
> + ? ? ? ? ? ? ? ? ? ? ? gpios = <&gpio 4 1 0>; /* GPI_P3 1 */
> ? ? ? ? ? ? ? ?};
> ? ? ? ?};
> ?};
On Sun, Jun 24, 2012 at 10:47 AM, Roland Stigge <[email protected]> wrote:
> This defconfig update for LPC32xx adds interrupt and polled gpio keyboard
> drivers.
>
> Signed-off-by: Roland Stigge <[email protected]>
Acked-by: Alexandre Pereira da Silva <[email protected]>
> ---
> ?arch/arm/configs/lpc32xx_defconfig | ? ?2 ++
> ?1 file changed, 2 insertions(+)
>
> --- linux-2.6.orig/arch/arm/configs/lpc32xx_defconfig
> +++ linux-2.6/arch/arm/configs/lpc32xx_defconfig
> @@ -18,6 +18,7 @@ CONFIG_MODULE_UNLOAD=y
> ?# CONFIG_BLK_DEV_BSG is not set
> ?CONFIG_PARTITION_ADVANCED=y
> ?CONFIG_ARCH_LPC32XX=y
> +CONFIG_KEYBOARD_GPIO_POLLED=y
> ?CONFIG_PREEMPT=y
> ?CONFIG_AEABI=y
> ?CONFIG_ZBOOT_ROM_TEXT=0x0
> @@ -89,6 +90,7 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_X=240
> ?CONFIG_INPUT_MOUSEDEV_SCREEN_Y=320
> ?CONFIG_INPUT_EVDEV=y
> ?# CONFIG_KEYBOARD_ATKBD is not set
> +CONFIG_KEYBOARD_GPIO=y
> ?CONFIG_KEYBOARD_LPC32XX=y
> ?# CONFIG_INPUT_MOUSE is not set
> ?CONFIG_INPUT_TOUCHSCREEN=y