Skip to contentSkip to conversation

Genesi Efika MX/SB support improvements

PATCH Superseded Arnaud Patard (Rtp) 2 participants 11 messages Feb 2, 2011

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Genesi Efika MX/SB support improvements

Hi,

This patch series aims at improving current efika mx support and adds support for efika smartbook. Given the similarities between the two systems, the first patch moves mx some code into a new file which will contain code shared by both systems and the last patch adds support for efika smartbook.

Arnaud

#2 lore raw

PATCH 1/5 Introduce EFIKA_COMMON

Quoted 14 lines · Arnaud Patard

The Genesi EFIKA MX and EFIKA Smartbook are sharing a lot of things so it makes sense to create a common file for both devices and a specific file for each. No functionnal change except dropping uart 1 & 2.

(quoted diff) +8 -0
+
+/* Serial ports */
+#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
+static const struct imxuart_platform_data uart_pdata = {
+	.flags = IMXUART_HAVE_RTSCTS,
+};
+
+static inline void mxc_init_imx_uart(void)

Review

Quoted 10 lines
(quoted diff) +10 -0
+{
+	imx51_add_imx_uart(0, &uart_pdata);
+	imx51_add_imx_uart(1, &uart_pdata);
+	imx51_add_imx_uart(2, &uart_pdata);
+}
+#else /* !SERIAL_IMX */
+static inline void mxc_init_imx_uart(void)
+{
+}
+#endif /* SERIAL_IMX */

Please remove the ifdefs around the serial port initialization. Also, I remember that the efikamx only has one serial port connected.

Quoted 19 lines
(quoted diff) +19 -0
+
+/* This function is board specific as the bit mask for the plldiv will also
+ * be different for other Freescale SoCs, thus a common bitmask is not
+ * possible and cannot get place in /plat-mxc/ehci.c.
+ */
+static int initialize_otg_port(struct platform_device *pdev)
+{
+	u32 v;
+	void __iomem *usb_base;
+	void __iomem *usbother_base;
+	usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
+	if (!usb_base)
+		return -ENOMEM;
+	usbother_base = (void __iomem *)(usb_base + MX5_USBOTHER_REGS_OFFSET);
+
+	/* Set the PHY clock to 19.2MHz */
+	v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
+	v &= ~MX5_USB_UTMI_PHYCTRL1_PLLDIV_MASK;
+	v |= MX51_USB_PLL_DIV_24_MHZ;

Review

Quoted 10 lines
(quoted diff) +10 -0
+	__raw_writel(v, usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
+	iounmap(usb_base);
+	return 0;
+}
+
+static struct mxc_usbh_platform_data dr_utmi_config = {
+	.init   = initialize_otg_port,
+	.portsc = MXC_EHCI_UTMI_16BIT,
+	.flags  = MXC_EHCI_INTERNAL_PHY,
+};

Could you rebase this on the ehci cleanup patches I recently sent and thereby also test the patches for your board?

Sascha

Signature · 4 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 |
#3 lore raw

PATCH 1/5 Introduce EFIKA_COMMON

Quoted 20 lines · Sascha Hauer
Quoted 19 lines · Arnaud Patard

The Genesi EFIKA MX and EFIKA Smartbook are sharing a lot of things so it makes sense to create a common file for both devices and a specific file for each. No functionnal change except dropping uart 1 & 2.

(quoted diff) +13 -0
+
+/* Serial ports */
+#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
+static const struct imxuart_platform_data uart_pdata = {
+	.flags = IMXUART_HAVE_RTSCTS,
+};
+
+static inline void mxc_init_imx_uart(void)
+{
+	imx51_add_imx_uart(0, &uart_pdata);
+	imx51_add_imx_uart(1, &uart_pdata);
+	imx51_add_imx_uart(2, &uart_pdata);
+}
Quoted 9 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+#else /* !SERIAL_IMX */
+static inline void mxc_init_imx_uart(void)
+{
+}
+#endif /* SERIAL_IMX */

Please remove the ifdefs around the serial port initialization. Also, I remember that the efikamx only has one serial port connected.

doh. It's dead code. I've modified the code in init() to use only one uart but forgot to kill that :(

Quoted 24 lines
Quoted 24 lines
(quoted diff) +24 -0
+
+/* This function is board specific as the bit mask for the plldiv will also
+ * be different for other Freescale SoCs, thus a common bitmask is not
+ * possible and cannot get place in /plat-mxc/ehci.c.
+ */
+static int initialize_otg_port(struct platform_device *pdev)
+{
+	u32 v;
+	void __iomem *usb_base;
+	void __iomem *usbother_base;
+	usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
+	if (!usb_base)
+		return -ENOMEM;
+	usbother_base = (void __iomem *)(usb_base + MX5_USBOTHER_REGS_OFFSET);
+
+	/* Set the PHY clock to 19.2MHz */
+	v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
+	v &= ~MX5_USB_UTMI_PHYCTRL1_PLLDIV_MASK;
+	v |= MX51_USB_PLL_DIV_24_MHZ;
+	__raw_writel(v, usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
+	iounmap(usb_base);
+	return 0;
+}
+
Quoted 8 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+static struct mxc_usbh_platform_data dr_utmi_config = {
+	.init   = initialize_otg_port,
+	.portsc = MXC_EHCI_UTMI_16BIT,
+	.flags  = MXC_EHCI_INTERNAL_PHY,
+};

Could you rebase this on the ehci cleanup patches I recently sent and thereby also test the patches for your board?

I was wondering how to handle my patches vs your ehci cleanup. Nice to know how you want to handle it. Will test and report if anything goes wrong.

Arnaud

#6 lore raw

PATCH 3/5 efikamx: add mc13892 support / implement power off

Hi Arnaud,

Quoted 8 lines · Arnaud Patard

This patch declares regulators for the efikamx. Use it also to power off the efikamx.
Unfortunately, on the efikamx to2 boards, this doesn't work but they allow to power off by setting GPIO 4 13 to high level instead of powering off through the mc13892.

[...]

Quoted 66 lines

Index: linux-2.6-submit/arch/arm/mach-mx5/board-mx51_efikamx.c
===================================================================

arch/arm/mach-mx5/board-mx51_efikamx.c +37 -0
@@ -25,6 +25,9 @@
 #include <linux/fsl_devices.h>
 #include <linux/spi/flash.h>
 #include <linux/spi/spi.h>
+#include <linux/mfd/mc13892.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/consumer.h>
 
 #include <mach/common.h>
 #include <mach/hardware.h>
@@ -56,6 +59,10 @@
 #define EFIKAMX_RESET1_1	IMX_GPIO_NR(3, 2)
 #define EFIKAMX_RESET		IMX_GPIO_NR(1, 4)
 
+#define EFIKAMX_POWEROFF	IMX_GPIO_NR(4, 13)
+
+#define EFIKAMX_PMIC		IMX_GPIO_NR(1, 6)
+
 /* the pci ids pin have pull up. they're driven low according to board id */
 #define MX51_PAD_PCBID0	IOMUX_PAD(0x518, 0x130, 3, 0x0,   0, PAD_CTL_PUS_100K_UP)
 #define MX51_PAD_PCBID1	IOMUX_PAD(0x51C, 0x134, 3, 0x0,   0, PAD_CTL_PUS_100K_UP)
@@ -79,6 +86,9 @@
 	/* reset */
 	MX51_PAD_DI1_PIN13__GPIO3_2,
 	MX51_PAD_GPIO1_4__GPIO1_4,
+
+	/* power off */
+	MX51_PAD_CSI2_VSYNC__GPIO4_13,
 };
 
 /*   PCBID2  PCBID1 PCBID0  STATE
@@ -187,6 +197,44 @@
 		gpio_direction_output(EFIKAMX_RESET, 0);
 }
 
+static struct regulator *pwgt1, *pwgt2, *coincell;
+
+static void mx51_efikamx_power_off(void)
+{
+	if (!IS_ERR(coincell))
+		regulator_disable(coincell);
+
+	if (!IS_ERR(pwgt1) && !IS_ERR(pwgt2)) {
+		regulator_disable(pwgt2);
+		regulator_disable(pwgt1);
+	}
+	gpio_direction_output(EFIKAMX_POWEROFF, 1);
+}
+
+static int __init mx51_efikamx_power_init(void)
+{
+	pwgt1 = regulator_get(NULL, "pwgt1");
+	pwgt2 = regulator_get(NULL, "pwgt2");
+	if (!IS_ERR(pwgt1) && !IS_ERR(pwgt2)) {
+		regulator_enable(pwgt1);
+		regulator_enable(pwgt2);
+	}
+	gpio_request(EFIKAMX_POWEROFF, "poweroff");
+	pm_power_off = mx51_efikamx_power_off;
+
+	/* enable coincell charger. maybe need a small power driver ? */
+	coincell = regulator_get(NULL, "coincell");

arch/arm/mach-mx5/board-mx51_efikamx.c line 236

Quoted 10 lines
arch/arm/mach-mx5/board-mx51_efikamx.c +10 -0
+	if (!IS_ERR(coincell)) {
+		regulator_set_voltage(coincell, 3000000, 3000000);
+		regulator_enable(coincell);
+	}
+
+	regulator_has_full_constraints();
+
+	return 0;
+}
+late_initcall(mx51_efikamx_power_init);

Please always protect these board specific initcalls with a machine_is_*. Just because efikamx support is compiled into the kernel doesn't mean it's the only machine this kernel will run on.

Signature · 4 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 |
#7 lore raw

PATCH 3/5 efikamx: add mc13892 support / implement power off

Quoted 86 lines · Sascha Hauer

Hi Arnaud,

Quoted 8 lines · Arnaud Patard

This patch declares regulators for the efikamx. Use it also to power off the efikamx.
Unfortunately, on the efikamx to2 boards, this doesn't work but they allow to power off by setting GPIO 4 13 to high level instead of powering off through the mc13892.

[...]

Quoted 72 lines

Index: linux-2.6-submit/arch/arm/mach-mx5/board-mx51_efikamx.c
===================================================================

arch/arm/mach-mx5/board-mx51_efikamx.c +43 -0
@@ -25,6 +25,9 @@
 #include <linux/fsl_devices.h>
 #include <linux/spi/flash.h>
 #include <linux/spi/spi.h>
+#include <linux/mfd/mc13892.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/consumer.h>
 
 #include <mach/common.h>
 #include <mach/hardware.h>
@@ -56,6 +59,10 @@
 #define EFIKAMX_RESET1_1	IMX_GPIO_NR(3, 2)
 #define EFIKAMX_RESET		IMX_GPIO_NR(1, 4)
 
+#define EFIKAMX_POWEROFF	IMX_GPIO_NR(4, 13)
+
+#define EFIKAMX_PMIC		IMX_GPIO_NR(1, 6)
+
 /* the pci ids pin have pull up. they're driven low according to board id */
 #define MX51_PAD_PCBID0	IOMUX_PAD(0x518, 0x130, 3, 0x0,   0, PAD_CTL_PUS_100K_UP)
 #define MX51_PAD_PCBID1	IOMUX_PAD(0x51C, 0x134, 3, 0x0,   0, PAD_CTL_PUS_100K_UP)
@@ -79,6 +86,9 @@
 	/* reset */
 	MX51_PAD_DI1_PIN13__GPIO3_2,
 	MX51_PAD_GPIO1_4__GPIO1_4,
+
+	/* power off */
+	MX51_PAD_CSI2_VSYNC__GPIO4_13,
 };
 
 /*   PCBID2  PCBID1 PCBID0  STATE
@@ -187,6 +197,44 @@
 		gpio_direction_output(EFIKAMX_RESET, 0);
 }
 
+static struct regulator *pwgt1, *pwgt2, *coincell;
+
+static void mx51_efikamx_power_off(void)
+{
+	if (!IS_ERR(coincell))
+		regulator_disable(coincell);
+
+	if (!IS_ERR(pwgt1) && !IS_ERR(pwgt2)) {
+		regulator_disable(pwgt2);
+		regulator_disable(pwgt1);
+	}
+	gpio_direction_output(EFIKAMX_POWEROFF, 1);
+}
+
+static int __init mx51_efikamx_power_init(void)
+{
+	pwgt1 = regulator_get(NULL, "pwgt1");
+	pwgt2 = regulator_get(NULL, "pwgt2");
+	if (!IS_ERR(pwgt1) && !IS_ERR(pwgt2)) {
+		regulator_enable(pwgt1);
+		regulator_enable(pwgt2);
+	}
+	gpio_request(EFIKAMX_POWEROFF, "poweroff");
+	pm_power_off = mx51_efikamx_power_off;
+
+	/* enable coincell charger. maybe need a small power driver ? */
+	coincell = regulator_get(NULL, "coincell");
+	if (!IS_ERR(coincell)) {
+		regulator_set_voltage(coincell, 3000000, 3000000);
+		regulator_enable(coincell);
+	}
+
+	regulator_has_full_constraints();
Quoted 8 lines

arch/arm/mach-mx5/board-mx51_efikamx.c line 236

Quoted 4 lines
arch/arm/mach-mx5/board-mx51_efikamx.c +4 -0
+
+	return 0;
+}
+late_initcall(mx51_efikamx_power_init);

Please always protect these board specific initcalls with a machine_is_*. Just because efikamx support is compiled into the kernel doesn't mean it's the only machine this kernel will run on.

ok. fixed here and in sb code. I'm using the same kernel on sb & mx but the diff are small in this part so I didn't notice. I'm going to test if things are still ok with the proper checks.

Arnaud

#10 lore raw

PATCH 5/5 mx51: add support for efika smartbook

Quoted 5 lines · Arnaud Patard

Index: linux-2.6-submit/arch/arm/mach-mx5/board-mx51_efikasb.c
===================================================================

arch/arm/mach-mx5/board-mx51_efikasb.c new file +0 -0

[...]

Quoted 7 lines
arch/arm/mach-mx5/board-mx51_efikasb.c new file +7 -0
+
+static int __init mx51_efikasb_power_init(void)
+{
+	pwgt1 = regulator_get(NULL, "pwgt1");
+	pwgt2 = regulator_get(NULL, "pwgt2");
+	if (!IS_ERR(pwgt1) && !IS_ERR(pwgt2)) {
+		regulator_enable(pwgt1);

arch/arm/mach-mx5/board-mx51_efikasb.c

Quoted 10 lines
arch/arm/mach-mx5/board-mx51_efikasb.c new file +10 -0
+		regulator_enable(pwgt2);
+	}
+	gpio_request(EFIKASB_POWEROFF, "poweroff");
+	pm_power_off = mx51_efikasb_power_off;
+
+	regulator_has_full_constraints();
+
+	return 0;
+}
+late_initcall(mx51_efikasb_power_init);

This also needs protection against other machines.

Sascha

Signature · 4 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 |