summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Beisert <j.beisert@pengutronix.de>2009-02-20 11:52:30 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2009-02-20 11:52:30 +0100
commit6e13a5be3b7096d217d7d594e950ac1caba65e2c (patch)
treefc797e3231f83b9c4d33a850b2086615e50d2d81
parent10b2fc60c48eccc468ecfede8ace3a43b8439b33 (diff)
downloadlinux-2.6-6e13a5be3b7096d217d7d594e950ac1caba65e2c.tar.gz
linux-2.6-6e13a5be3b7096d217d7d594e950ac1caba65e2c.tar.xz
pcm038: Extend to current development status
This patch expands the pcm038 BSP to the current development status. These features are not part of the base patchset. New devices are: - spi - i2c - framebuffer Note: This is for development. Not for mainline yet. Signed-off-by: Juergen Beisert <j.beisert@pengutronix.de>
-rw-r--r--arch/arm/mach-mx2/pcm038.c149
-rw-r--r--arch/arm/mach-mx2/pcm970-baseboard.c71
2 files changed, 220 insertions, 0 deletions
diff --git a/arch/arm/mach-mx2/pcm038.c b/arch/arm/mach-mx2/pcm038.c
index 5bdf083da14..d5673b7e641 100644
--- a/arch/arm/mach-mx2/pcm038.c
+++ b/arch/arm/mach-mx2/pcm038.c
@@ -18,6 +18,8 @@
#include <linux/platform_device.h>
#include <linux/mtd/physmap.h>
+#include <linux/i2c.h>
+#include <linux/spi/spi.h>
#include <linux/serial.h>
#include <asm/arch/common.h>
#include <asm/hardware.h>
@@ -25,7 +27,10 @@
#include <asm/mach/arch.h>
#include <asm/arch/clock.h>
#include <asm/arch/gpio.h>
+#include <asm/arch/imx_i2c.h>
+#include <asm/arch/imx_spi.h>
#include <asm/arch/imx_uart.h>
+#include <asm/arch/pmic/platform.h>
#include "serial.h"
#include "devices.h"
#include "gpio_mux.h"
@@ -54,6 +59,137 @@ static struct platform_device pcm038_nor_mtd_device = {
.resource = &pcm038_flash_resource,
};
+#ifdef CONFIG_I2C
+static int pcm038_i2c_1_init(struct platform_device *pdev)
+{
+ gpio_request_mux(MX27_PIN_I2C2_SCL, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_I2C2_SDA, GPIO_MUX_PRIMARY);
+ return 0;
+}
+
+static int pcm038_i2c_1_exit(struct platform_device *pdev)
+{
+ gpio_free_mux(MX27_PIN_I2C2_SCL);
+ gpio_free_mux(MX27_PIN_I2C2_SDA);
+ return 0;
+}
+
+static struct imx_i2c_platform_data pcm038_i2c_1_data = {
+ .i2c_clk = 100000,
+ .init = pcm038_i2c_1_init,
+ .exit = pcm038_i2c_1_exit,
+};
+
+static struct i2c_board_info pcm038_i2c_devices[] = {
+ [0] = {
+ .driver_name = "st24cxx",
+ .type = "m24c32",
+ .flags = 0, /* FIXME */
+ .addr = 0x52, /* E0=0, E1=1, E2=0 */
+ .platform_data = NULL,
+ .irq = 0
+ },
+ [1] = {
+ .driver_name = "rtc-pcf8563",
+ .type = "rtc8564",
+ .flags = 0, /* FIXME */
+ .addr = 0x51,
+ .platform_data = NULL,
+ .irq = 0
+ },
+ [2] = {
+ .driver_name = "lm75",
+ .type = "",
+ .flags = 0,
+ .addr = 0x4a,
+ .platform_data = NULL,
+ .irq = 0
+ }
+};
+#endif
+
+static int gpio_spi_active_0(struct platform_device *pdev)
+{
+ gpio_request_mux(MX27_PIN_CSPI1_MOSI, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_CSPI1_MISO, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_CSPI1_SCLK, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_CSPI1_RDY, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_CSPI1_SS0, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_CSPI1_SS1, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_CSPI1_SS2, GPIO_MUX_PRIMARY); /* pcm038: we don't have this one */
+ return 0;
+}
+
+static int gpio_spi_active_2(struct platform_device *pdev)
+{
+ gpio_request_mux(MX27_PIN_SD1_D0, GPIO_MUX_ALT);
+ gpio_request_mux(MX27_PIN_SD1_CMD, GPIO_MUX_ALT);
+ gpio_request_mux(MX27_PIN_SD1_CLK, GPIO_MUX_ALT);
+ gpio_request_mux(MX27_PIN_SD1_D3, GPIO_MUX_ALT);
+ return 0;
+}
+
+static int gpio_spi_inactive_0(struct platform_device *pdev)
+{
+ gpio_free_mux(MX27_PIN_CSPI1_MOSI);
+ gpio_free_mux(MX27_PIN_CSPI1_MISO);
+ gpio_free_mux(MX27_PIN_CSPI1_SCLK);
+ gpio_free_mux(MX27_PIN_CSPI1_RDY);
+ gpio_free_mux(MX27_PIN_CSPI1_SS0);
+ gpio_free_mux(MX27_PIN_CSPI1_SS1);
+ gpio_free_mux(MX27_PIN_CSPI1_SS2);
+ return 0;
+}
+
+static int gpio_spi_inactive_2(struct platform_device *pdev)
+{
+ gpio_free_mux(MX27_PIN_SD1_D0);
+ gpio_free_mux(MX27_PIN_SD1_CMD);
+ gpio_free_mux(MX27_PIN_SD1_CLK);
+ gpio_free_mux(MX27_PIN_SD1_D3);
+ return 0;
+}
+
+static struct mxc_spi_master pcm038_spi_0_data = {
+ .maxchipselect = 4, /* FIXME */
+ .spi_version = 0, /* ??????????????? */
+ .init = gpio_spi_active_0,
+ .exit = gpio_spi_inactive_0,
+};
+
+static int gpio_pmic_active(void)
+{
+ gpio_config_mux(MX27_PIN_USB_PWR, GPIO_MUX_GPIO);
+ mxc_set_gpio_direction(MX27_PIN_USB_PWR, 1);
+ return 0;
+}
+
+static struct pmic_platform_data pcm038_pmic_irq = {
+ .init = gpio_pmic_active,
+ .exit = NULL /* TODO required? */
+};
+
+/*
+ * spi bus 1 description
+ * - serviced by SPI master unit 1 (be seen in kernel as #0)
+ * - SS0 selects the external MC13783
+ * - MC13783's interrupt is connected to PB23
+ * - SS1: external available
+ * - SS2: external available
+ * - SS3: external available
+ * FIXME: does this use the spi init functions correctly?
+ */
+static struct spi_board_info pcm038_spi_board_info[] __initdata = {
+ {
+ .modalias = "pmic_spi",
+ .irq = PCM038_PMIC_INT_LINE,
+ .max_speed_hz = /* 4000000 */ 3000000, /* FIXME: Depends on internal PLL? */
+ .bus_num = PCM038_PMIC_SPI_CHANNEL,
+ .chip_select = 0,
+ .platform_data = &pcm038_pmic_irq
+ }
+};
+
static int uart_mxc_port0_init(struct platform_device *pdev)
{
gpio_request_mux(MX27_PIN_UART1_TXD, GPIO_MUX_PRIMARY);
@@ -182,6 +318,19 @@ static void __init pcm038_init(void)
mxc_init_uart(1, 0, uart_mxc_port1_init, uart_mxc_port1_exit);
mxc_init_uart(2, 0, uart_mxc_port2_init, uart_mxc_port2_exit);
+#ifdef CONFIG_I2C
+ /* only the i2c master 1 is used on this CPU card */
+ i2c_register_board_info(PCM038_I2C_BUS, pcm038_i2c_devices,
+ ARRAY_SIZE(pcm038_i2c_devices));
+
+ mxc_init_i2c(1, &pcm038_i2c_1_data);
+#endif
+
+ mxc_init_spi(0, &pcm038_spi_0_data);
+
+ spi_register_board_info(pcm038_spi_board_info,
+ ARRAY_SIZE(pcm038_spi_board_info));
+
platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
#ifdef CONFIG_MACH_PCM970_BASEBOARD
diff --git a/arch/arm/mach-mx2/pcm970-baseboard.c b/arch/arm/mach-mx2/pcm970-baseboard.c
index e25ede5edb9..f01d394c3c8 100644
--- a/arch/arm/mach-mx2/pcm970-baseboard.c
+++ b/arch/arm/mach-mx2/pcm970-baseboard.c
@@ -16,12 +16,79 @@
*/
#include <linux/platform_device.h>
+#include <linux/i2c.h>
#include <asm/hardware.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
+#include <asm/arch/imx_i2c.h>
+#include <asm/arch/imx_fb.h>
#include "devices.h"
#include "gpio_mux.h"
+static int pcm038_i2c_0_init(struct platform_device *pdev)
+{
+ gpio_request_mux(MX27_PIN_I2C_CLK, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_I2C_DATA, GPIO_MUX_PRIMARY);
+ return 0;
+}
+
+static int pcm038_i2c_0_exit(struct platform_device *pdev)
+{
+ gpio_free_mux(MX27_PIN_I2C_CLK);
+ gpio_free_mux(MX27_PIN_I2C2_SDA);
+ return 0;
+}
+
+static struct imx_i2c_platform_data pcm038_i2c_0_data = {
+ .i2c_clk = 100000,
+ .init = pcm038_i2c_0_init,
+ .exit = pcm038_i2c_0_exit,
+};
+
+static int pcm038_fb_init(struct platform_device *pdev)
+{
+ gpio_request_mux(MX27_PIN_LSCLK, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD0, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD1, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD2, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD3, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD4, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD5, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD6, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD7, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD8, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD9, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD10, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD11, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD12, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD13, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD14, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD15, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD16, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_LD17, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_REV, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_CLS, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_PS, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_SPL_SPR, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_HSYNC, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_VSYNC, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_CONTRAST, GPIO_MUX_PRIMARY);
+ gpio_request_mux(MX27_PIN_OE_ACD, GPIO_MUX_PRIMARY);
+ return 0;
+}
+
+static int pcm038_fb_exit(struct platform_device *pdev)
+{
+ dev_info(&pdev->dev, "%s: implement me\n", __FUNCTION__);
+ return 0;
+}
+
+static struct mxc_fb_platform_data pcm038_fb_data = {
+ .mode = "Sharp-QVGA",
+ .init = pcm038_fb_init,
+ .exit = pcm038_fb_exit,
+};
+
/*
* system init for baseboard usage. Will be called by pcm038 init.
*
@@ -30,4 +97,8 @@
*/
void __init pcm970_baseboard_init(void)
{
+ /* the first i2c master is used for devices on the baseboard */
+ mxc_init_i2c(0, &pcm038_i2c_0_data);
+
+ mxc_init_fb(&pcm038_fb_data);
}