]> rtime.felk.cvut.cz Git - mcf548x/linux.git/blob - arch/m68k/coldfire/m547x_8x-devices.c
Current (FEC from 2.6.31 port, no CAN, no I2C, no PCI)
[mcf548x/linux.git] / arch / m68k / coldfire / m547x_8x-devices.c
1 /*
2  * arch/m68k/coldfire/m547x_8x-devices.c
3  *
4  * Coldfire M547x/M548x Platform Device Configuration
5  *
6  * Copyright (c) 2008 Freescale Semiconductor, Inc.
7  *      Kurt Mahan <kmahan@freescale.com>
8  */
9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/fsl_devices.h>
14 #include <linux/spi/spi.h>
15
16 #include <asm/coldfire.h>
17 #include <asm/mcfsim.h>
18 #include <asm/mcfqspi.h>
19
20
21 #ifdef CONFIG_SPI
22 /*
23  *
24  * DSPI
25  *
26  */
27
28 /* number of supported SPI selects */
29 #define SPI_NUM_CHIPSELECTS     8
30
31 void coldfire_spi_cs_control(u8 cs, u8 command)
32 {
33         /* nothing special required */
34 }
35
36 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
37 static struct coldfire_spi_chip spidev_chip_info = {
38         .bits_per_word = 8,
39 };
40 #endif
41
42 static struct spi_board_info spi_board_info[] = {
43 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
44         {
45                 .modalias = "spidev",
46                 .max_speed_hz = 16000000,       /* max clk (SCK) speed in HZ */
47                 .bus_num = 1,
48                 .chip_select = 0,               /* CS0 */
49                 .controller_data = &spidev_chip_info,
50         }
51 #endif
52 };
53
54 static int spi_irq_list[] = {
55         /* IRQ,              ICR Offset,        ICR Val,Mask */
56         64 + ISC_DSPI_OVRFW, ISC_DSPI_OVRFW,    0x18,   0,
57         64 + ISC_DSPI_RFOF,  ISC_DSPI_RFOF,     0x18,   0,
58         64 + ISC_DSPI_RFDF,  ISC_DSPI_RFDF,     0x18,   0,
59         64 + ISC_DSPI_TFUF,  ISC_DSPI_TFUF,     0x18,   0,
60         64 + ISC_DSPI_TCF,   ISC_DSPI_TCF,      0x18,   0,
61         64 + ISC_DSPI_TFFF,  ISC_DSPI_TFFF,     0x18,   0,
62         64 + ISC_DSPI_EOQF,  ISC_DSPI_EOQF,     0x18,   0,
63         0,0,0,0,
64 };
65
66 static struct coldfire_spi_master coldfire_master_info = {
67         .bus_num = 1,
68         .num_chipselect = SPI_NUM_CHIPSELECTS,
69         .irq_list = spi_irq_list,
70         .irq_source = 0,        /* not used */
71         .irq_vector = 0,        /* not used */
72         .irq_mask = 0,          /* not used */
73         .irq_lp = 0,            /* not used */
74         .par_val = 0,           /* not used */
75         .cs_control = coldfire_spi_cs_control,
76 };
77
78 static struct resource coldfire_spi_resources[] = {
79         [0] = {
80                 .name = "spi-par",
81                 .start = MCF_MBAR + 0x00000a50, /* PAR_DSPI */
82                 .end = MCF_MBAR + 0x00000a50,   /* PAR_DSPI */
83                 .flags = IORESOURCE_MEM
84         },
85
86         [1] = {
87                 .name = "spi-module",
88                 .start = MCF_MBAR + 0x00008a00, /* DSPI MCR Base */
89                 .end = MCF_MBAR + 0x00008ab8,   /* DSPI mem map end */
90                 .flags = IORESOURCE_MEM
91         },
92
93         [2] = {
94                 .name = "spi-int-level",
95                 .start = MCF_MBAR + 0x740,               /* ICR start */
96                 .end = MCF_MBAR + 0x740 + ISC_DSPI_EOQF, /* ICR end */
97                 .flags = IORESOURCE_MEM
98         },
99
100         [3] = {
101                 .name = "spi-int-mask",
102                 .start = MCF_MBAR + 0x70c,      /* IMRL */
103                 .end = MCF_MBAR + 0x70c,        /* IMRL */
104                 .flags = IORESOURCE_MEM
105         }
106 };
107
108 static struct platform_device coldfire_spi = {
109         .name = "spi_coldfire",
110         .id = -1,
111         .resource = coldfire_spi_resources,
112         .num_resources = ARRAY_SIZE(coldfire_spi_resources),
113         .dev = {
114                 .platform_data = &coldfire_master_info,
115         }
116 };
117
118 /**
119  * m547x_8x_spi_init - Initialize SPI
120  */
121 static int __init m547x_8x_spi_init(void)
122 {
123         int retval;
124
125         /* initialize the DSPI PAR */
126         MCF_GPIO_PAR_DSPI = (MCF_GPIO_PAR_DSPI_PAR_CS5 |
127                              MCF_GPIO_PAR_DSPI_PAR_CS3_DSPICS |
128                              MCF_GPIO_PAR_DSPI_PAR_CS2_DSPICS |
129                              MCF_GPIO_PAR_DSPI_PAR_CS0_DSPICS |
130                              MCF_GPIO_PAR_DSPI_PAR_SCK_SCK |
131                              MCF_GPIO_PAR_DSPI_PAR_SIN_SIN |
132                              MCF_GPIO_PAR_DSPI_PAR_SOUT_SOUT);
133
134         /* register device */
135         retval = platform_device_register(&coldfire_spi);
136         if (retval < 0) {
137                 goto out;
138         }
139
140         /* register board info */
141         if (ARRAY_SIZE(spi_board_info))
142                 retval = spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
143
144 out:
145         return retval;
146 }
147 #endif
148
149
150 /**
151  * m547x_8x_init_devices - Initialize M547X_8X devices
152  *
153  * Returns 0 on success.
154  */
155 static int __init m547x_8x_init_devices(void)
156 {
157 #ifdef CONFIG_SPI
158         m547x_8x_spi_init();
159 #endif
160
161         return 0;
162 }
163 arch_initcall(m547x_8x_init_devices);