aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-23 19:17:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-23 19:17:43 -0400
commit4f2d658b2f09c41677871a4285a09cf35f954dad (patch)
treeec0a626a598530203871bbc37a340224e5ac87ad /drivers
parente66d637134b7045ea6f14bdd416cd3695f73ed42 (diff)
parent1fc5f7d5c680ac36bd41e13a3d77cbe2eaa312e0 (diff)
Merge tag 'dt' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull arm-soc device tree description updates from Arnd Bergmann: "This branch contains two kinds of updates: Some platforms in the process of getting converted to device tree based booting, and the platform specific patches necessary for that are included here. Other platforms are already converted, so we just need to update the actual device tree source files and the binding documents to add support for new board and new drivers. In the future we will probably separate those into two branches, and in the long run, the plan is to move the device tree source files out of the kernel repository, but that has to wait until we have completed a much larger portion of the binding documents." Fix up trivial conflicts in arch/arm/mach-imx/clk-imx6q.c due to newly added clkdev registers next to a few removed unnecessary ones. * tag 'dt' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (119 commits) ARM: LPC32xx: Add PWM to base dts file ARM: EXYNOS: mark the DMA channel binding for SPI as preliminary ARM: dts: Add nodes for spi controllers for SAMSUNG EXYNOS5 platforms ARM: EXYNOS: Enable platform support for SPI controllers for EXYNOS5 ARM: EXYNOS: Add spi clock support for EXYNOS5 ARM: dts: Add nodes for spi controllers for SAMSUNG EXYNOS4 platforms ARM: EXYNOS: Enable platform support for SPI controllers for EXYNOX4 ARM: EXYNOS: Fix the incorrect hierarchy of spi controller bus clock ARM: ux500: Remove PMU platform registration when booting with DT ARM: ux500: Remove temporary snowball_of_platform_devs enablement structure ARM: ux500: Ensure vendor specific properties have the vendor's identifier pinctrl: pinctrl-nomadik: Append sleepmode property with vendor specific prefixes ARM: ux500: Move rtc-pl031 registration to Device Tree when enabled ARM: ux500: Enable the AB8500 RTC for all DT:ed DB8500 based devices ARM: ux500: Correctly reference IRQs supplied by the AB8500 from Device Tree ARM: ux500: Apply ab8500-debug node do the db8500 DT structure ARM: ux500: Add a ab8500-usb Device Tree node for db8500 based devices ARM: ux500: Add db8500 Device Tree node for misc/ab8500-pwm ARM: ux500: Add db8500 Device Tree node for ab8500-sysctrl ARM: ux500: Enable LED heartbeat functionality on Snowbal via DT ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/busses/i2c-nomadik.c3
-rw-r--r--drivers/pinctrl/pinctrl-nomadik.c2
-rw-r--r--drivers/rtc/rtc-stmp3xxx.c8
-rw-r--r--drivers/spi/spi-s3c64xx.c481
-rw-r--r--drivers/tty/serial/mxs-auart.c42
-rw-r--r--drivers/video/mxsfb.c62
-rw-r--r--drivers/watchdog/omap_wdt.c7
7 files changed, 514 insertions, 91 deletions
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 5267ab93d550..a92440dbef07 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -965,8 +965,7 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev)
965 adap->owner = THIS_MODULE; 965 adap->owner = THIS_MODULE;
966 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 966 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
967 adap->algo = &nmk_i2c_algo; 967 adap->algo = &nmk_i2c_algo;
968 adap->timeout = pdata->timeout ? msecs_to_jiffies(pdata->timeout) : 968 adap->timeout = msecs_to_jiffies(pdata->timeout);
969 msecs_to_jiffies(20000);
970 snprintf(adap->name, sizeof(adap->name), 969 snprintf(adap->name, sizeof(adap->name),
971 "Nomadik I2C%d at %lx", pdev->id, (unsigned long)res->start); 970 "Nomadik I2C%d at %lx", pdev->id, (unsigned long)res->start);
972 971
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
index 3e7e47d6b385..dd9e6f26416d 100644
--- a/drivers/pinctrl/pinctrl-nomadik.c
+++ b/drivers/pinctrl/pinctrl-nomadik.c
@@ -1198,7 +1198,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
1198 if (!pdata) 1198 if (!pdata)
1199 return -ENOMEM; 1199 return -ENOMEM;
1200 1200
1201 if (of_get_property(np, "supports-sleepmode", NULL)) 1201 if (of_get_property(np, "st,supports-sleepmode", NULL))
1202 pdata->supports_sleepmode = true; 1202 pdata->supports_sleepmode = true;
1203 1203
1204 if (of_property_read_u32(np, "gpio-bank", &dev->id)) { 1204 if (of_property_read_u32(np, "gpio-bank", &dev->id)) {
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index 10287865e330..739ef55694f4 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -25,6 +25,7 @@
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/rtc.h> 26#include <linux/rtc.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/of_device.h>
28 29
29#include <mach/common.h> 30#include <mach/common.h>
30 31
@@ -265,6 +266,12 @@ static int stmp3xxx_rtc_resume(struct platform_device *dev)
265#define stmp3xxx_rtc_resume NULL 266#define stmp3xxx_rtc_resume NULL
266#endif 267#endif
267 268
269static const struct of_device_id rtc_dt_ids[] = {
270 { .compatible = "fsl,stmp3xxx-rtc", },
271 { /* sentinel */ }
272};
273MODULE_DEVICE_TABLE(of, rtc_dt_ids);
274
268static struct platform_driver stmp3xxx_rtcdrv = { 275static struct platform_driver stmp3xxx_rtcdrv = {
269 .probe = stmp3xxx_rtc_probe, 276 .probe = stmp3xxx_rtc_probe,
270 .remove = stmp3xxx_rtc_remove, 277 .remove = stmp3xxx_rtc_remove,
@@ -273,6 +280,7 @@ static struct platform_driver stmp3xxx_rtcdrv = {
273 .driver = { 280 .driver = {
274 .name = "stmp3xxx-rtc", 281 .name = "stmp3xxx-rtc",
275 .owner = THIS_MODULE, 282 .owner = THIS_MODULE,
283 .of_match_table = rtc_dt_ids,
276 }, 284 },
277}; 285};
278 286
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 3c36cfaa1b93..0dedbbdb153a 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -27,10 +27,15 @@
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/pm_runtime.h> 28#include <linux/pm_runtime.h>
29#include <linux/spi/spi.h> 29#include <linux/spi/spi.h>
30#include <linux/gpio.h>
31#include <linux/of.h>
32#include <linux/of_gpio.h>
30 33
31#include <mach/dma.h> 34#include <mach/dma.h>
32#include <plat/s3c64xx-spi.h> 35#include <plat/s3c64xx-spi.h>
33 36
37#define MAX_SPI_PORTS 3
38
34/* Registers and bit-fields */ 39/* Registers and bit-fields */
35 40
36#define S3C64XX_SPI_CH_CFG 0x00 41#define S3C64XX_SPI_CH_CFG 0x00
@@ -113,13 +118,12 @@
113 118
114#define S3C64XX_SPI_FBCLK_MSK (3<<0) 119#define S3C64XX_SPI_FBCLK_MSK (3<<0)
115 120
116#define S3C64XX_SPI_ST_TRLCNTZ(v, i) ((((v) >> (i)->rx_lvl_offset) & \ 121#define FIFO_LVL_MASK(i) ((i)->port_conf->fifo_lvl_mask[i->port_id])
117 (((i)->fifo_lvl_mask + 1))) \ 122#define S3C64XX_SPI_ST_TX_DONE(v, i) (((v) & \
118 ? 1 : 0) 123 (1 << (i)->port_conf->tx_st_done)) ? 1 : 0)
119 124#define TX_FIFO_LVL(v, i) (((v) >> 6) & FIFO_LVL_MASK(i))
120#define S3C64XX_SPI_ST_TX_DONE(v, i) (((v) & (1 << (i)->tx_st_done)) ? 1 : 0) 125#define RX_FIFO_LVL(v, i) (((v) >> (i)->port_conf->rx_lvl_offset) & \
121#define TX_FIFO_LVL(v, i) (((v) >> 6) & (i)->fifo_lvl_mask) 126 FIFO_LVL_MASK(i))
122#define RX_FIFO_LVL(v, i) (((v) >> (i)->rx_lvl_offset) & (i)->fifo_lvl_mask)
123 127
124#define S3C64XX_SPI_MAX_TRAILCNT 0x3ff 128#define S3C64XX_SPI_MAX_TRAILCNT 0x3ff
125#define S3C64XX_SPI_TRAILCNT_OFF 19 129#define S3C64XX_SPI_TRAILCNT_OFF 19
@@ -135,6 +139,29 @@ struct s3c64xx_spi_dma_data {
135 unsigned ch; 139 unsigned ch;
136 enum dma_data_direction direction; 140 enum dma_data_direction direction;
137 enum dma_ch dmach; 141 enum dma_ch dmach;
142 struct property *dma_prop;
143};
144
145/**
146 * struct s3c64xx_spi_info - SPI Controller hardware info
147 * @fifo_lvl_mask: Bit-mask for {TX|RX}_FIFO_LVL bits in SPI_STATUS register.
148 * @rx_lvl_offset: Bit offset of RX_FIFO_LVL bits in SPI_STATUS regiter.
149 * @tx_st_done: Bit offset of TX_DONE bit in SPI_STATUS regiter.
150 * @high_speed: True, if the controller supports HIGH_SPEED_EN bit.
151 * @clk_from_cmu: True, if the controller does not include a clock mux and
152 * prescaler unit.
153 *
154 * The Samsung s3c64xx SPI controller are used on various Samsung SoC's but
155 * differ in some aspects such as the size of the fifo and spi bus clock
156 * setup. Such differences are specified to the driver using this structure
157 * which is provided as driver data to the driver.
158 */
159struct s3c64xx_spi_port_config {
160 int fifo_lvl_mask[MAX_SPI_PORTS];
161 int rx_lvl_offset;
162 int tx_st_done;
163 bool high_speed;
164 bool clk_from_cmu;
138}; 165};
139 166
140/** 167/**
@@ -175,6 +202,9 @@ struct s3c64xx_spi_driver_data {
175 struct s3c64xx_spi_dma_data rx_dma; 202 struct s3c64xx_spi_dma_data rx_dma;
176 struct s3c64xx_spi_dma_data tx_dma; 203 struct s3c64xx_spi_dma_data tx_dma;
177 struct samsung_dma_ops *ops; 204 struct samsung_dma_ops *ops;
205 struct s3c64xx_spi_port_config *port_conf;
206 unsigned int port_id;
207 unsigned long gpios[4];
178}; 208};
179 209
180static struct s3c2410_dma_client s3c64xx_spi_dma_client = { 210static struct s3c2410_dma_client s3c64xx_spi_dma_client = {
@@ -183,7 +213,6 @@ static struct s3c2410_dma_client s3c64xx_spi_dma_client = {
183 213
184static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) 214static void flush_fifo(struct s3c64xx_spi_driver_data *sdd)
185{ 215{
186 struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
187 void __iomem *regs = sdd->regs; 216 void __iomem *regs = sdd->regs;
188 unsigned long loops; 217 unsigned long loops;
189 u32 val; 218 u32 val;
@@ -199,7 +228,7 @@ static void flush_fifo(struct s3c64xx_spi_driver_data *sdd)
199 loops = msecs_to_loops(1); 228 loops = msecs_to_loops(1);
200 do { 229 do {
201 val = readl(regs + S3C64XX_SPI_STATUS); 230 val = readl(regs + S3C64XX_SPI_STATUS);
202 } while (TX_FIFO_LVL(val, sci) && loops--); 231 } while (TX_FIFO_LVL(val, sdd) && loops--);
203 232
204 if (loops == 0) 233 if (loops == 0)
205 dev_warn(&sdd->pdev->dev, "Timed out flushing TX FIFO\n"); 234 dev_warn(&sdd->pdev->dev, "Timed out flushing TX FIFO\n");
@@ -208,7 +237,7 @@ static void flush_fifo(struct s3c64xx_spi_driver_data *sdd)
208 loops = msecs_to_loops(1); 237 loops = msecs_to_loops(1);
209 do { 238 do {
210 val = readl(regs + S3C64XX_SPI_STATUS); 239 val = readl(regs + S3C64XX_SPI_STATUS);
211 if (RX_FIFO_LVL(val, sci)) 240 if (RX_FIFO_LVL(val, sdd))
212 readl(regs + S3C64XX_SPI_RX_DATA); 241 readl(regs + S3C64XX_SPI_RX_DATA);
213 else 242 else
214 break; 243 break;
@@ -301,7 +330,9 @@ static int acquire_dma(struct s3c64xx_spi_driver_data *sdd)
301 req.cap = DMA_SLAVE; 330 req.cap = DMA_SLAVE;
302 req.client = &s3c64xx_spi_dma_client; 331 req.client = &s3c64xx_spi_dma_client;
303 332
333 req.dt_dmach_prop = sdd->rx_dma.dma_prop;
304 sdd->rx_dma.ch = sdd->ops->request(sdd->rx_dma.dmach, &req); 334 sdd->rx_dma.ch = sdd->ops->request(sdd->rx_dma.dmach, &req);
335 req.dt_dmach_prop = sdd->tx_dma.dma_prop;
305 sdd->tx_dma.ch = sdd->ops->request(sdd->tx_dma.dmach, &req); 336 sdd->tx_dma.ch = sdd->ops->request(sdd->tx_dma.dmach, &req);
306 337
307 return 1; 338 return 1;
@@ -311,7 +342,6 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd,
311 struct spi_device *spi, 342 struct spi_device *spi,
312 struct spi_transfer *xfer, int dma_mode) 343 struct spi_transfer *xfer, int dma_mode)
313{ 344{
314 struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
315 void __iomem *regs = sdd->regs; 345 void __iomem *regs = sdd->regs;
316 u32 modecfg, chcfg; 346 u32 modecfg, chcfg;
317 347
@@ -361,7 +391,7 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd,
361 if (xfer->rx_buf != NULL) { 391 if (xfer->rx_buf != NULL) {
362 sdd->state |= RXBUSY; 392 sdd->state |= RXBUSY;
363 393
364 if (sci->high_speed && sdd->cur_speed >= 30000000UL 394 if (sdd->port_conf->high_speed && sdd->cur_speed >= 30000000UL
365 && !(sdd->cur_mode & SPI_CPHA)) 395 && !(sdd->cur_mode & SPI_CPHA))
366 chcfg |= S3C64XX_SPI_CH_HS_EN; 396 chcfg |= S3C64XX_SPI_CH_HS_EN;
367 397
@@ -388,20 +418,19 @@ static inline void enable_cs(struct s3c64xx_spi_driver_data *sdd,
388 if (sdd->tgl_spi != spi) { /* if last mssg on diff device */ 418 if (sdd->tgl_spi != spi) { /* if last mssg on diff device */
389 /* Deselect the last toggled device */ 419 /* Deselect the last toggled device */
390 cs = sdd->tgl_spi->controller_data; 420 cs = sdd->tgl_spi->controller_data;
391 cs->set_level(cs->line, 421 gpio_set_value(cs->line,
392 spi->mode & SPI_CS_HIGH ? 0 : 1); 422 spi->mode & SPI_CS_HIGH ? 0 : 1);
393 } 423 }
394 sdd->tgl_spi = NULL; 424 sdd->tgl_spi = NULL;
395 } 425 }
396 426
397 cs = spi->controller_data; 427 cs = spi->controller_data;
398 cs->set_level(cs->line, spi->mode & SPI_CS_HIGH ? 1 : 0); 428 gpio_set_value(cs->line, spi->mode & SPI_CS_HIGH ? 1 : 0);
399} 429}
400 430
401static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd, 431static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd,
402 struct spi_transfer *xfer, int dma_mode) 432 struct spi_transfer *xfer, int dma_mode)
403{ 433{
404 struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
405 void __iomem *regs = sdd->regs; 434 void __iomem *regs = sdd->regs;
406 unsigned long val; 435 unsigned long val;
407 int ms; 436 int ms;
@@ -418,7 +447,7 @@ static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd,
418 val = msecs_to_loops(ms); 447 val = msecs_to_loops(ms);
419 do { 448 do {
420 status = readl(regs + S3C64XX_SPI_STATUS); 449 status = readl(regs + S3C64XX_SPI_STATUS);
421 } while (RX_FIFO_LVL(status, sci) < xfer->len && --val); 450 } while (RX_FIFO_LVL(status, sdd) < xfer->len && --val);
422 } 451 }
423 452
424 if (!val) 453 if (!val)
@@ -437,8 +466,8 @@ static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd,
437 if (xfer->rx_buf == NULL) { 466 if (xfer->rx_buf == NULL) {
438 val = msecs_to_loops(10); 467 val = msecs_to_loops(10);
439 status = readl(regs + S3C64XX_SPI_STATUS); 468 status = readl(regs + S3C64XX_SPI_STATUS);
440 while ((TX_FIFO_LVL(status, sci) 469 while ((TX_FIFO_LVL(status, sdd)
441 || !S3C64XX_SPI_ST_TX_DONE(status, sci)) 470 || !S3C64XX_SPI_ST_TX_DONE(status, sdd))
442 && --val) { 471 && --val) {
443 cpu_relax(); 472 cpu_relax();
444 status = readl(regs + S3C64XX_SPI_STATUS); 473 status = readl(regs + S3C64XX_SPI_STATUS);
@@ -482,17 +511,16 @@ static inline void disable_cs(struct s3c64xx_spi_driver_data *sdd,
482 if (sdd->tgl_spi == spi) 511 if (sdd->tgl_spi == spi)
483 sdd->tgl_spi = NULL; 512 sdd->tgl_spi = NULL;
484 513
485 cs->set_level(cs->line, spi->mode & SPI_CS_HIGH ? 0 : 1); 514 gpio_set_value(cs->line, spi->mode & SPI_CS_HIGH ? 0 : 1);
486} 515}
487 516
488static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd) 517static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
489{ 518{
490 struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
491 void __iomem *regs = sdd->regs; 519 void __iomem *regs = sdd->regs;
492 u32 val; 520 u32 val;
493 521
494 /* Disable Clock */ 522 /* Disable Clock */
495 if (sci->clk_from_cmu) { 523 if (sdd->port_conf->clk_from_cmu) {
496 clk_disable(sdd->src_clk); 524 clk_disable(sdd->src_clk);
497 } else { 525 } else {
498 val = readl(regs + S3C64XX_SPI_CLK_CFG); 526 val = readl(regs + S3C64XX_SPI_CLK_CFG);
@@ -536,7 +564,7 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
536 564
537 writel(val, regs + S3C64XX_SPI_MODE_CFG); 565 writel(val, regs + S3C64XX_SPI_MODE_CFG);
538 566
539 if (sci->clk_from_cmu) { 567 if (sdd->port_conf->clk_from_cmu) {
540 /* Configure Clock */ 568 /* Configure Clock */
541 /* There is half-multiplier before the SPI */ 569 /* There is half-multiplier before the SPI */
542 clk_set_rate(sdd->src_clk, sdd->cur_speed * 2); 570 clk_set_rate(sdd->src_clk, sdd->cur_speed * 2);
@@ -562,7 +590,6 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
562static int s3c64xx_spi_map_mssg(struct s3c64xx_spi_driver_data *sdd, 590static int s3c64xx_spi_map_mssg(struct s3c64xx_spi_driver_data *sdd,
563 struct spi_message *msg) 591 struct spi_message *msg)
564{ 592{
565 struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
566 struct device *dev = &sdd->pdev->dev; 593 struct device *dev = &sdd->pdev->dev;
567 struct spi_transfer *xfer; 594 struct spi_transfer *xfer;
568 595
@@ -578,7 +605,7 @@ static int s3c64xx_spi_map_mssg(struct s3c64xx_spi_driver_data *sdd,
578 /* Map until end or first fail */ 605 /* Map until end or first fail */
579 list_for_each_entry(xfer, &msg->transfers, transfer_list) { 606 list_for_each_entry(xfer, &msg->transfers, transfer_list) {
580 607
581 if (xfer->len <= ((sci->fifo_lvl_mask >> 1) + 1)) 608 if (xfer->len <= ((FIFO_LVL_MASK(sdd) >> 1) + 1))
582 continue; 609 continue;
583 610
584 if (xfer->tx_buf != NULL) { 611 if (xfer->tx_buf != NULL) {
@@ -612,7 +639,6 @@ static int s3c64xx_spi_map_mssg(struct s3c64xx_spi_driver_data *sdd,
612static void s3c64xx_spi_unmap_mssg(struct s3c64xx_spi_driver_data *sdd, 639static void s3c64xx_spi_unmap_mssg(struct s3c64xx_spi_driver_data *sdd,
613 struct spi_message *msg) 640 struct spi_message *msg)
614{ 641{
615 struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
616 struct device *dev = &sdd->pdev->dev; 642 struct device *dev = &sdd->pdev->dev;
617 struct spi_transfer *xfer; 643 struct spi_transfer *xfer;
618 644
@@ -621,7 +647,7 @@ static void s3c64xx_spi_unmap_mssg(struct s3c64xx_spi_driver_data *sdd,
621 647
622 list_for_each_entry(xfer, &msg->transfers, transfer_list) { 648 list_for_each_entry(xfer, &msg->transfers, transfer_list) {
623 649
624 if (xfer->len <= ((sci->fifo_lvl_mask >> 1) + 1)) 650 if (xfer->len <= ((FIFO_LVL_MASK(sdd) >> 1) + 1))
625 continue; 651 continue;
626 652
627 if (xfer->rx_buf != NULL 653 if (xfer->rx_buf != NULL
@@ -640,7 +666,6 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,
640 struct spi_message *msg) 666 struct spi_message *msg)
641{ 667{
642 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); 668 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
643 struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
644 struct spi_device *spi = msg->spi; 669 struct spi_device *spi = msg->spi;
645 struct s3c64xx_spi_csinfo *cs = spi->controller_data; 670 struct s3c64xx_spi_csinfo *cs = spi->controller_data;
646 struct spi_transfer *xfer; 671 struct spi_transfer *xfer;
@@ -695,7 +720,7 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,
695 } 720 }
696 721
697 /* Polling method for xfers not bigger than FIFO capacity */ 722 /* Polling method for xfers not bigger than FIFO capacity */
698 if (xfer->len <= ((sci->fifo_lvl_mask >> 1) + 1)) 723 if (xfer->len <= ((FIFO_LVL_MASK(sdd) >> 1) + 1))
699 use_dma = 0; 724 use_dma = 0;
700 else 725 else
701 use_dma = 1; 726 use_dma = 1;
@@ -800,6 +825,48 @@ static int s3c64xx_spi_unprepare_transfer(struct spi_master *spi)
800 return 0; 825 return 0;
801} 826}
802 827
828static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
829 struct s3c64xx_spi_driver_data *sdd,
830 struct spi_device *spi)
831{
832 struct s3c64xx_spi_csinfo *cs;
833 struct device_node *slave_np, *data_np;
834 u32 fb_delay = 0;
835
836 slave_np = spi->dev.of_node;
837 if (!slave_np) {
838 dev_err(&spi->dev, "device node not found\n");
839 return ERR_PTR(-EINVAL);
840 }
841
842 for_each_child_of_node(slave_np, data_np)
843 if (!strcmp(data_np->name, "controller-data"))
844 break;
845 if (!data_np) {
846 dev_err(&spi->dev, "child node 'controller-data' not found\n");
847 return ERR_PTR(-EINVAL);
848 }
849
850 cs = kzalloc(sizeof(*cs), GFP_KERNEL);
851 if (!cs) {
852 dev_err(&spi->dev, "could not allocate memory for controller"
853 " data\n");
854 return ERR_PTR(-ENOMEM);
855 }
856
857 cs->line = of_get_named_gpio(data_np, "cs-gpio", 0);
858 if (!gpio_is_valid(cs->line)) {
859 dev_err(&spi->dev, "chip select gpio is not specified or "
860 "invalid\n");
861 kfree(cs);
862 return ERR_PTR(-EINVAL);
863 }
864
865 of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay);
866 cs->fb_delay = fb_delay;
867 return cs;
868}
869
803/* 870/*
804 * Here we only check the validity of requested configuration 871 * Here we only check the validity of requested configuration
805 * and save the configuration in a local data-structure. 872 * and save the configuration in a local data-structure.
@@ -813,14 +880,30 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
813 struct s3c64xx_spi_info *sci; 880 struct s3c64xx_spi_info *sci;
814 struct spi_message *msg; 881 struct spi_message *msg;
815 unsigned long flags; 882 unsigned long flags;
816 int err = 0; 883 int err;
817 884
818 if (cs == NULL || cs->set_level == NULL) { 885 sdd = spi_master_get_devdata(spi->master);
886 if (!cs && spi->dev.of_node) {
887 cs = s3c64xx_get_slave_ctrldata(sdd, spi);
888 spi->controller_data = cs;
889 }
890
891 if (IS_ERR_OR_NULL(cs)) {
819 dev_err(&spi->dev, "No CS for SPI(%d)\n", spi->chip_select); 892 dev_err(&spi->dev, "No CS for SPI(%d)\n", spi->chip_select);
820 return -ENODEV; 893 return -ENODEV;
821 } 894 }
822 895
823 sdd = spi_master_get_devdata(spi->master); 896 if (!spi_get_ctldata(spi)) {
897 err = gpio_request(cs->line, dev_name(&spi->dev));
898 if (err) {
899 dev_err(&spi->dev, "request for slave select gpio "
900 "line [%d] failed\n", cs->line);
901 err = -EBUSY;
902 goto err_gpio_req;
903 }
904 spi_set_ctldata(spi, cs);
905 }
906
824 sci = sdd->cntrlr_info; 907 sci = sdd->cntrlr_info;
825 908
826 spin_lock_irqsave(&sdd->lock, flags); 909 spin_lock_irqsave(&sdd->lock, flags);
@@ -831,7 +914,8 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
831 dev_err(&spi->dev, 914 dev_err(&spi->dev,
832 "setup: attempt while mssg in queue!\n"); 915 "setup: attempt while mssg in queue!\n");
833 spin_unlock_irqrestore(&sdd->lock, flags); 916 spin_unlock_irqrestore(&sdd->lock, flags);
834 return -EBUSY; 917 err = -EBUSY;
918 goto err_msgq;
835 } 919 }
836 } 920 }
837 921
@@ -849,7 +933,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
849 pm_runtime_get_sync(&sdd->pdev->dev); 933 pm_runtime_get_sync(&sdd->pdev->dev);
850 934
851 /* Check if we can provide the requested rate */ 935 /* Check if we can provide the requested rate */
852 if (!sci->clk_from_cmu) { 936 if (!sdd->port_conf->clk_from_cmu) {
853 u32 psr, speed; 937 u32 psr, speed;
854 938
855 /* Max possible */ 939 /* Max possible */
@@ -874,22 +958,44 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
874 } 958 }
875 959
876 speed = clk_get_rate(sdd->src_clk) / 2 / (psr + 1); 960 speed = clk_get_rate(sdd->src_clk) / 2 / (psr + 1);
877 if (spi->max_speed_hz >= speed) 961 if (spi->max_speed_hz >= speed) {
878 spi->max_speed_hz = speed; 962 spi->max_speed_hz = speed;
879 else 963 } else {
880 err = -EINVAL; 964 err = -EINVAL;
965 goto setup_exit;
966 }
881 } 967 }
882 968
883 pm_runtime_put(&sdd->pdev->dev); 969 pm_runtime_put(&sdd->pdev->dev);
970 disable_cs(sdd, spi);
971 return 0;
884 972
885setup_exit: 973setup_exit:
886
887 /* setup() returns with device de-selected */ 974 /* setup() returns with device de-selected */
888 disable_cs(sdd, spi); 975 disable_cs(sdd, spi);
889 976
977err_msgq:
978 gpio_free(cs->line);
979 spi_set_ctldata(spi, NULL);
980
981err_gpio_req:
982 kfree(cs);
983
890 return err; 984 return err;
891} 985}
892 986
987static void s3c64xx_spi_cleanup(struct spi_device *spi)
988{
989 struct s3c64xx_spi_csinfo *cs = spi_get_ctldata(spi);
990
991 if (cs) {
992 gpio_free(cs->line);
993 if (spi->dev.of_node)
994 kfree(cs);
995 }
996 spi_set_ctldata(spi, NULL);
997}
998
893static irqreturn_t s3c64xx_spi_irq(int irq, void *data) 999static irqreturn_t s3c64xx_spi_irq(int irq, void *data)
894{ 1000{
895 struct s3c64xx_spi_driver_data *sdd = data; 1001 struct s3c64xx_spi_driver_data *sdd = data;
@@ -930,7 +1036,7 @@ static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel)
930 /* Disable Interrupts - we use Polling if not DMA mode */ 1036 /* Disable Interrupts - we use Polling if not DMA mode */
931 writel(0, regs + S3C64XX_SPI_INT_EN); 1037 writel(0, regs + S3C64XX_SPI_INT_EN);
932 1038
933 if (!sci->clk_from_cmu) 1039 if (!sdd->port_conf->clk_from_cmu)
934 writel(sci->src_clk_nr << S3C64XX_SPI_CLKSEL_SRCSHFT, 1040 writel(sci->src_clk_nr << S3C64XX_SPI_CLKSEL_SRCSHFT,
935 regs + S3C64XX_SPI_CLK_CFG); 1041 regs + S3C64XX_SPI_CLK_CFG);
936 writel(0, regs + S3C64XX_SPI_MODE_CFG); 1042 writel(0, regs + S3C64XX_SPI_MODE_CFG);
@@ -951,40 +1057,164 @@ static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel)
951 flush_fifo(sdd); 1057 flush_fifo(sdd);
952} 1058}
953 1059
954static int __init s3c64xx_spi_probe(struct platform_device *pdev) 1060static int __devinit s3c64xx_spi_get_dmares(
1061 struct s3c64xx_spi_driver_data *sdd, bool tx)
1062{
1063 struct platform_device *pdev = sdd->pdev;
1064 struct s3c64xx_spi_dma_data *dma_data;
1065 struct property *prop;
1066 struct resource *res;
1067 char prop_name[15], *chan_str;
1068
1069 if (tx) {
1070 dma_data = &sdd->tx_dma;
1071 dma_data->direction = DMA_TO_DEVICE;
1072 chan_str = "tx";
1073 } else {
1074 dma_data = &sdd->rx_dma;
1075 dma_data->direction = DMA_FROM_DEVICE;
1076 chan_str = "rx";
1077 }
1078
1079 if (!sdd->pdev->dev.of_node) {
1080 res = platform_get_resource(pdev, IORESOURCE_DMA, tx ? 0 : 1);
1081 if (!res) {
1082 dev_err(&pdev->dev, "Unable to get SPI-%s dma "
1083 "resource\n", chan_str);
1084 return -ENXIO;
1085 }
1086 dma_data->dmach = res->start;
1087 return 0;
1088 }
1089
1090 sprintf(prop_name, "%s-dma-channel", chan_str);
1091 prop = of_find_property(pdev->dev.of_node, prop_name, NULL);
1092 if (!prop) {
1093 dev_err(&pdev->dev, "%s dma channel property not specified\n",
1094 chan_str);
1095 return -ENXIO;
1096 }
1097
1098 dma_data->dmach = DMACH_DT_PROP;
1099 dma_data->dma_prop = prop;
1100 return 0;
1101}
1102
1103#ifdef CONFIG_OF
1104static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd)
1105{
1106 struct device *dev = &sdd->pdev->dev;
1107 int idx, gpio, ret;
1108
1109 /* find gpios for mosi, miso and clock lines */
1110 for (idx = 0; idx < 3; idx++) {
1111 gpio = of_get_gpio(dev->of_node, idx);
1112 if (!gpio_is_valid(gpio)) {
1113 dev_err(dev, "invalid gpio[%d]: %d\n", idx, gpio);
1114 goto free_gpio;
1115 }
1116
1117 ret = gpio_request(gpio, "spi-bus");
1118 if (ret) {
1119 dev_err(dev, "gpio [%d] request failed\n", gpio);
1120 goto free_gpio;
1121 }
1122 }
1123 return 0;
1124
1125free_gpio:
1126 while (--idx >= 0)
1127 gpio_free(sdd->gpios[idx]);
1128 return -EINVAL;
1129}
1130
1131static void s3c64xx_spi_dt_gpio_free(struct s3c64xx_spi_driver_data *sdd)
1132{
1133 unsigned int idx;
1134 for (idx = 0; idx < 3; idx++)
1135 gpio_free(sdd->gpios[idx]);
1136}
1137
1138static struct __devinit s3c64xx_spi_info * s3c64xx_spi_parse_dt(
1139 struct device *dev)
955{ 1140{
956 struct resource *mem_res, *dmatx_res, *dmarx_res;
957 struct s3c64xx_spi_driver_data *sdd;
958 struct s3c64xx_spi_info *sci; 1141 struct s3c64xx_spi_info *sci;
959 struct spi_master *master; 1142 u32 temp;
960 int ret, irq;
961 char clk_name[16];
962 1143
963 if (pdev->id < 0) { 1144 sci = devm_kzalloc(dev, sizeof(*sci), GFP_KERNEL);
964 dev_err(&pdev->dev, 1145 if (!sci) {
965 "Invalid platform device id-%d\n", pdev->id); 1146 dev_err(dev, "memory allocation for spi_info failed\n");
966 return -ENODEV; 1147 return ERR_PTR(-ENOMEM);
967 } 1148 }
968 1149
969 if (pdev->dev.platform_data == NULL) { 1150 if (of_property_read_u32(dev->of_node, "samsung,spi-src-clk", &temp)) {
970 dev_err(&pdev->dev, "platform_data missing!\n"); 1151 dev_warn(dev, "spi bus clock parent not specified, using "
971 return -ENODEV; 1152 "clock at index 0 as parent\n");
1153 sci->src_clk_nr = 0;
1154 } else {
1155 sci->src_clk_nr = temp;
972 } 1156 }
973 1157
974 sci = pdev->dev.platform_data; 1158 if (of_property_read_u32(dev->of_node, "num-cs", &temp)) {
1159 dev_warn(dev, "number of chip select lines not specified, "
1160 "assuming 1 chip select line\n");
1161 sci->num_cs = 1;
1162 } else {
1163 sci->num_cs = temp;
1164 }
1165
1166 return sci;
1167}
1168#else
1169static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev)
1170{
1171 return dev->platform_data;
1172}
1173
1174static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd)
1175{
1176 return -EINVAL;
1177}
975 1178
976 /* Check for availability of necessary resource */ 1179static void s3c64xx_spi_dt_gpio_free(struct s3c64xx_spi_driver_data *sdd)
1180{
1181}
1182#endif
977 1183
978 dmatx_res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 1184static const struct of_device_id s3c64xx_spi_dt_match[];
979 if (dmatx_res == NULL) { 1185
980 dev_err(&pdev->dev, "Unable to get SPI-Tx dma resource\n"); 1186static inline struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config(
981 return -ENXIO; 1187 struct platform_device *pdev)
1188{
1189#ifdef CONFIG_OF
1190 if (pdev->dev.of_node) {
1191 const struct of_device_id *match;
1192 match = of_match_node(s3c64xx_spi_dt_match, pdev->dev.of_node);
1193 return (struct s3c64xx_spi_port_config *)match->data;
982 } 1194 }
1195#endif
1196 return (struct s3c64xx_spi_port_config *)
1197 platform_get_device_id(pdev)->driver_data;
1198}
983 1199
984 dmarx_res = platform_get_resource(pdev, IORESOURCE_DMA, 1); 1200static int __init s3c64xx_spi_probe(struct platform_device *pdev)
985 if (dmarx_res == NULL) { 1201{
986 dev_err(&pdev->dev, "Unable to get SPI-Rx dma resource\n"); 1202 struct resource *mem_res;
987 return -ENXIO; 1203 struct s3c64xx_spi_driver_data *sdd;
1204 struct s3c64xx_spi_info *sci = pdev->dev.platform_data;
1205 struct spi_master *master;
1206 int ret, irq;
1207 char clk_name[16];
1208
1209 if (!sci && pdev->dev.of_node) {
1210 sci = s3c64xx_spi_parse_dt(&pdev->dev);
1211 if (IS_ERR(sci))
1212 return PTR_ERR(sci);
1213 }
1214
1215 if (!sci) {
1216 dev_err(&pdev->dev, "platform_data missing!\n");
1217 return -ENODEV;
988 } 1218 }
989 1219
990 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1220 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1009,19 +1239,37 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1009 platform_set_drvdata(pdev, master); 1239 platform_set_drvdata(pdev, master);
1010 1240
1011 sdd = spi_master_get_devdata(master); 1241 sdd = spi_master_get_devdata(master);
1242 sdd->port_conf = s3c64xx_spi_get_port_config(pdev);
1012 sdd->master = master; 1243 sdd->master = master;
1013 sdd->cntrlr_info = sci; 1244 sdd->cntrlr_info = sci;
1014 sdd->pdev = pdev; 1245 sdd->pdev = pdev;
1015 sdd->sfr_start = mem_res->start; 1246 sdd->sfr_start = mem_res->start;
1016 sdd->tx_dma.dmach = dmatx_res->start; 1247 if (pdev->dev.of_node) {
1017 sdd->tx_dma.direction = DMA_MEM_TO_DEV; 1248 ret = of_alias_get_id(pdev->dev.of_node, "spi");
1018 sdd->rx_dma.dmach = dmarx_res->start; 1249 if (ret < 0) {
1019 sdd->rx_dma.direction = DMA_DEV_TO_MEM; 1250 dev_err(&pdev->dev, "failed to get alias id, "
1251 "errno %d\n", ret);
1252 goto err0;
1253 }
1254 sdd->port_id = ret;
1255 } else {
1256 sdd->port_id = pdev->id;
1257 }
1020 1258
1021 sdd->cur_bpw = 8; 1259 sdd->cur_bpw = 8;
1022 1260
1023 master->bus_num = pdev->id; 1261 ret = s3c64xx_spi_get_dmares(sdd, true);
1262 if (ret)
1263 goto err0;
1264
1265 ret = s3c64xx_spi_get_dmares(sdd, false);
1266 if (ret)
1267 goto err0;
1268
1269 master->dev.of_node = pdev->dev.of_node;
1270 master->bus_num = sdd->port_id;
1024 master->setup = s3c64xx_spi_setup; 1271 master->setup = s3c64xx_spi_setup;
1272 master->cleanup = s3c64xx_spi_cleanup;
1025 master->prepare_transfer_hardware = s3c64xx_spi_prepare_transfer; 1273 master->prepare_transfer_hardware = s3c64xx_spi_prepare_transfer;
1026 master->transfer_one_message = s3c64xx_spi_transfer_one_message; 1274 master->transfer_one_message = s3c64xx_spi_transfer_one_message;
1027 master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_transfer; 1275 master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_transfer;
@@ -1044,7 +1292,10 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1044 goto err1; 1292 goto err1;
1045 } 1293 }
1046 1294
1047 if (sci->cfg_gpio == NULL || sci->cfg_gpio(pdev)) { 1295 if (!sci->cfg_gpio && pdev->dev.of_node) {
1296 if (s3c64xx_spi_parse_dt_gpio(sdd))
1297 return -EBUSY;
1298 } else if (sci->cfg_gpio == NULL || sci->cfg_gpio()) {
1048 dev_err(&pdev->dev, "Unable to config gpio\n"); 1299 dev_err(&pdev->dev, "Unable to config gpio\n");
1049 ret = -EBUSY; 1300 ret = -EBUSY;
1050 goto err2; 1301 goto err2;
@@ -1080,7 +1331,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1080 } 1331 }
1081 1332
1082 /* Setup Deufult Mode */ 1333 /* Setup Deufult Mode */
1083 s3c64xx_spi_hwinit(sdd, pdev->id); 1334 s3c64xx_spi_hwinit(sdd, sdd->port_id);
1084 1335
1085 spin_lock_init(&sdd->lock); 1336 spin_lock_init(&sdd->lock);
1086 init_completion(&sdd->xfer_completion); 1337 init_completion(&sdd->xfer_completion);
@@ -1105,7 +1356,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1105 1356
1106 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d " 1357 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d "
1107 "with %d Slaves attached\n", 1358 "with %d Slaves attached\n",
1108 pdev->id, master->num_chipselect); 1359 sdd->port_id, master->num_chipselect);
1109 dev_dbg(&pdev->dev, "\tIOmem=[0x%x-0x%x]\tDMA=[Rx-%d, Tx-%d]\n", 1360 dev_dbg(&pdev->dev, "\tIOmem=[0x%x-0x%x]\tDMA=[Rx-%d, Tx-%d]\n",
1110 mem_res->end, mem_res->start, 1361 mem_res->end, mem_res->start,
1111 sdd->rx_dma.dmach, sdd->tx_dma.dmach); 1362 sdd->rx_dma.dmach, sdd->tx_dma.dmach);
@@ -1125,6 +1376,8 @@ err5:
1125err4: 1376err4:
1126 clk_put(sdd->clk); 1377 clk_put(sdd->clk);
1127err3: 1378err3:
1379 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node)
1380 s3c64xx_spi_dt_gpio_free(sdd);
1128err2: 1381err2:
1129 iounmap((void *) sdd->regs); 1382 iounmap((void *) sdd->regs);
1130err1: 1383err1:
@@ -1156,6 +1409,9 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)
1156 clk_disable(sdd->clk); 1409 clk_disable(sdd->clk);
1157 clk_put(sdd->clk); 1410 clk_put(sdd->clk);
1158 1411
1412 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node)
1413 s3c64xx_spi_dt_gpio_free(sdd);
1414
1159 iounmap((void *) sdd->regs); 1415 iounmap((void *) sdd->regs);
1160 1416
1161 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1417 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1180,6 +1436,9 @@ static int s3c64xx_spi_suspend(struct device *dev)
1180 clk_disable(sdd->src_clk); 1436 clk_disable(sdd->src_clk);
1181 clk_disable(sdd->clk); 1437 clk_disable(sdd->clk);
1182 1438
1439 if (!sdd->cntrlr_info->cfg_gpio && dev->of_node)
1440 s3c64xx_spi_dt_gpio_free(sdd);
1441
1183 sdd->cur_speed = 0; /* Output Clock is stopped */ 1442 sdd->cur_speed = 0; /* Output Clock is stopped */
1184 1443
1185 return 0; 1444 return 0;
@@ -1187,18 +1446,20 @@ static int s3c64xx_spi_suspend(struct device *dev)
1187 1446
1188static int s3c64xx_spi_resume(struct device *dev) 1447static int s3c64xx_spi_resume(struct device *dev)
1189{ 1448{
1190 struct platform_device *pdev = to_platform_device(dev);
1191 struct spi_master *master = spi_master_get(dev_get_drvdata(dev)); 1449 struct spi_master *master = spi_master_get(dev_get_drvdata(dev));
1192 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); 1450 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
1193 struct s3c64xx_spi_info *sci = sdd->cntrlr_info; 1451 struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
1194 1452
1195 sci->cfg_gpio(pdev); 1453 if (!sci->cfg_gpio && dev->of_node)
1454 s3c64xx_spi_parse_dt_gpio(sdd);
1455 else
1456 sci->cfg_gpio();
1196 1457
1197 /* Enable the clock */ 1458 /* Enable the clock */
1198 clk_enable(sdd->src_clk); 1459 clk_enable(sdd->src_clk);
1199 clk_enable(sdd->clk); 1460 clk_enable(sdd->clk);
1200 1461
1201 s3c64xx_spi_hwinit(sdd, pdev->id); 1462 s3c64xx_spi_hwinit(sdd, sdd->port_id);
1202 1463
1203 spi_master_resume(master); 1464 spi_master_resume(master);
1204 1465
@@ -1236,13 +1497,89 @@ static const struct dev_pm_ops s3c64xx_spi_pm = {
1236 s3c64xx_spi_runtime_resume, NULL) 1497 s3c64xx_spi_runtime_resume, NULL)
1237}; 1498};
1238 1499
1500struct s3c64xx_spi_port_config s3c2443_spi_port_config = {
1501 .fifo_lvl_mask = { 0x7f },
1502 .rx_lvl_offset = 13,
1503 .tx_st_done = 21,
1504 .high_speed = true,
1505};
1506
1507struct s3c64xx_spi_port_config s3c6410_spi_port_config = {
1508 .fifo_lvl_mask = { 0x7f, 0x7F },
1509 .rx_lvl_offset = 13,
1510 .tx_st_done = 21,
1511};
1512
1513struct s3c64xx_spi_port_config s5p64x0_spi_port_config = {
1514 .fifo_lvl_mask = { 0x1ff, 0x7F },
1515 .rx_lvl_offset = 15,
1516 .tx_st_done = 25,
1517};
1518
1519struct s3c64xx_spi_port_config s5pc100_spi_port_config = {
1520 .fifo_lvl_mask = { 0x7f, 0x7F },
1521 .rx_lvl_offset = 13,
1522 .tx_st_done = 21,
1523 .high_speed = true,
1524};
1525
1526struct s3c64xx_spi_port_config s5pv210_spi_port_config = {
1527 .fifo_lvl_mask = { 0x1ff, 0x7F },
1528 .rx_lvl_offset = 15,
1529 .tx_st_done = 25,
1530 .high_speed = true,
1531};
1532
1533struct s3c64xx_spi_port_config exynos4_spi_port_config = {
1534 .fifo_lvl_mask = { 0x1ff, 0x7F, 0x7F },
1535 .rx_lvl_offset = 15,
1536 .tx_st_done = 25,
1537 .high_speed = true,
1538 .clk_from_cmu = true,
1539};
1540
1541static struct platform_device_id s3c64xx_spi_driver_ids[] = {
1542 {
1543 .name = "s3c2443-spi",
1544 .driver_data = (kernel_ulong_t)&s3c2443_spi_port_config,
1545 }, {
1546 .name = "s3c6410-spi",
1547 .driver_data = (kernel_ulong_t)&s3c6410_spi_port_config,
1548 }, {
1549 .name = "s5p64x0-spi",
1550 .driver_data = (kernel_ulong_t)&s5p64x0_spi_port_config,
1551 }, {
1552 .name = "s5pc100-spi",
1553 .driver_data = (kernel_ulong_t)&s5pc100_spi_port_config,
1554 }, {
1555 .name = "s5pv210-spi",
1556 .driver_data = (kernel_ulong_t)&s5pv210_spi_port_config,
1557 }, {
1558 .name = "exynos4210-spi",
1559 .driver_data = (kernel_ulong_t)&exynos4_spi_port_config,
1560 },
1561 { },
1562};
1563
1564#ifdef CONFIG_OF
1565static const struct of_device_id s3c64xx_spi_dt_match[] = {
1566 { .compatible = "samsung,exynos4210-spi",
1567 .data = (void *)&exynos4_spi_port_config,
1568 },
1569 { },
1570};
1571MODULE_DEVICE_TABLE(of, s3c64xx_spi_dt_match);
1572#endif /* CONFIG_OF */
1573
1239static struct platform_driver s3c64xx_spi_driver = { 1574static struct platform_driver s3c64xx_spi_driver = {
1240 .driver = { 1575 .driver = {
1241 .name = "s3c64xx-spi", 1576 .name = "s3c64xx-spi",
1242 .owner = THIS_MODULE, 1577 .owner = THIS_MODULE,
1243 .pm = &s3c64xx_spi_pm, 1578 .pm = &s3c64xx_spi_pm,
1579 .of_match_table = of_match_ptr(s3c64xx_spi_dt_match),
1244 }, 1580 },
1245 .remove = s3c64xx_spi_remove, 1581 .remove = s3c64xx_spi_remove,
1582 .id_table = s3c64xx_spi_driver_ids,
1246}; 1583};
1247MODULE_ALIAS("platform:s3c64xx-spi"); 1584MODULE_ALIAS("platform:s3c64xx-spi");
1248 1585
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index ec56d8397aae..2e341b81ff89 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -33,6 +33,7 @@
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/io.h> 34#include <linux/io.h>
35#include <linux/pinctrl/consumer.h> 35#include <linux/pinctrl/consumer.h>
36#include <linux/of_device.h>
36 37
37#include <asm/cacheflush.h> 38#include <asm/cacheflush.h>
38 39
@@ -675,6 +676,30 @@ static struct uart_driver auart_driver = {
675#endif 676#endif
676}; 677};
677 678
679/*
680 * This function returns 1 if pdev isn't a device instatiated by dt, 0 if it
681 * could successfully get all information from dt or a negative errno.
682 */
683static int serial_mxs_probe_dt(struct mxs_auart_port *s,
684 struct platform_device *pdev)
685{
686 struct device_node *np = pdev->dev.of_node;
687 int ret;
688
689 if (!np)
690 /* no device tree device */
691 return 1;
692
693 ret = of_alias_get_id(np, "serial");
694 if (ret < 0) {
695 dev_err(&pdev->dev, "failed to get alias id: %d\n", ret);
696 return ret;
697 }
698 s->port.line = ret;
699
700 return 0;
701}
702
678static int __devinit mxs_auart_probe(struct platform_device *pdev) 703static int __devinit mxs_auart_probe(struct platform_device *pdev)
679{ 704{
680 struct mxs_auart_port *s; 705 struct mxs_auart_port *s;
@@ -689,6 +714,12 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
689 goto out; 714 goto out;
690 } 715 }
691 716
717 ret = serial_mxs_probe_dt(s, pdev);
718 if (ret > 0)
719 s->port.line = pdev->id < 0 ? 0 : pdev->id;
720 else if (ret < 0)
721 goto out_free;
722
692 pinctrl = devm_pinctrl_get_select_default(&pdev->dev); 723 pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
693 if (IS_ERR(pinctrl)) { 724 if (IS_ERR(pinctrl)) {
694 ret = PTR_ERR(pinctrl); 725 ret = PTR_ERR(pinctrl);
@@ -711,7 +742,6 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
711 s->port.membase = ioremap(r->start, resource_size(r)); 742 s->port.membase = ioremap(r->start, resource_size(r));
712 s->port.ops = &mxs_auart_ops; 743 s->port.ops = &mxs_auart_ops;
713 s->port.iotype = UPIO_MEM; 744 s->port.iotype = UPIO_MEM;
714 s->port.line = pdev->id < 0 ? 0 : pdev->id;
715 s->port.fifosize = 16; 745 s->port.fifosize = 16;
716 s->port.uartclk = clk_get_rate(s->clk); 746 s->port.uartclk = clk_get_rate(s->clk);
717 s->port.type = PORT_IMX; 747 s->port.type = PORT_IMX;
@@ -728,7 +758,7 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
728 758
729 platform_set_drvdata(pdev, s); 759 platform_set_drvdata(pdev, s);
730 760
731 auart_port[pdev->id] = s; 761 auart_port[s->port.line] = s;
732 762
733 mxs_auart_reset(&s->port); 763 mxs_auart_reset(&s->port);
734 764
@@ -769,12 +799,19 @@ static int __devexit mxs_auart_remove(struct platform_device *pdev)
769 return 0; 799 return 0;
770} 800}
771 801
802static struct of_device_id mxs_auart_dt_ids[] = {
803 { .compatible = "fsl,imx23-auart", },
804 { /* sentinel */ }
805};
806MODULE_DEVICE_TABLE(of, mxs_auart_dt_ids);
807
772static struct platform_driver mxs_auart_driver = { 808static struct platform_driver mxs_auart_driver = {
773 .probe = mxs_auart_probe, 809 .probe = mxs_auart_probe,
774 .remove = __devexit_p(mxs_auart_remove), 810 .remove = __devexit_p(mxs_auart_remove),
775 .driver = { 811 .driver = {
776 .name = "mxs-auart", 812 .name = "mxs-auart",
777 .owner = THIS_MODULE, 813 .owner = THIS_MODULE,
814 .of_match_table = mxs_auart_dt_ids,
778 }, 815 },
779}; 816};
780 817
@@ -807,3 +844,4 @@ module_init(mxs_auart_init);
807module_exit(mxs_auart_exit); 844module_exit(mxs_auart_exit);
808MODULE_LICENSE("GPL"); 845MODULE_LICENSE("GPL");
809MODULE_DESCRIPTION("Freescale MXS application uart driver"); 846MODULE_DESCRIPTION("Freescale MXS application uart driver");
847MODULE_ALIAS("platform:mxs-auart");
diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index abbe691047bd..49619b441500 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -41,12 +41,14 @@
41 41
42#include <linux/module.h> 42#include <linux/module.h>
43#include <linux/kernel.h> 43#include <linux/kernel.h>
44#include <linux/of_device.h>
45#include <linux/of_gpio.h>
44#include <linux/platform_device.h> 46#include <linux/platform_device.h>
45#include <linux/clk.h> 47#include <linux/clk.h>
46#include <linux/dma-mapping.h> 48#include <linux/dma-mapping.h>
47#include <linux/io.h> 49#include <linux/io.h>
48#include <linux/pinctrl/consumer.h> 50#include <linux/pinctrl/consumer.h>
49#include <mach/mxsfb.h> 51#include <linux/mxsfb.h>
50 52
51#define REG_SET 4 53#define REG_SET 4
52#define REG_CLR 8 54#define REG_CLR 8
@@ -750,16 +752,43 @@ static void __devexit mxsfb_free_videomem(struct mxsfb_info *host)
750 } 752 }
751} 753}
752 754
755static struct platform_device_id mxsfb_devtype[] = {
756 {
757 .name = "imx23-fb",
758 .driver_data = MXSFB_V3,
759 }, {
760 .name = "imx28-fb",
761 .driver_data = MXSFB_V4,
762 }, {
763 /* sentinel */
764 }
765};
766MODULE_DEVICE_TABLE(platform, mxsfb_devtype);
767
768static const struct of_device_id mxsfb_dt_ids[] = {
769 { .compatible = "fsl,imx23-lcdif", .data = &mxsfb_devtype[0], },
770 { .compatible = "fsl,imx28-lcdif", .data = &mxsfb_devtype[1], },
771 { /* sentinel */ }
772};
773MODULE_DEVICE_TABLE(of, mxsfb_dt_ids);
774
753static int __devinit mxsfb_probe(struct platform_device *pdev) 775static int __devinit mxsfb_probe(struct platform_device *pdev)
754{ 776{
777 const struct of_device_id *of_id =
778 of_match_device(mxsfb_dt_ids, &pdev->dev);
755 struct mxsfb_platform_data *pdata = pdev->dev.platform_data; 779 struct mxsfb_platform_data *pdata = pdev->dev.platform_data;
756 struct resource *res; 780 struct resource *res;
757 struct mxsfb_info *host; 781 struct mxsfb_info *host;
758 struct fb_info *fb_info; 782 struct fb_info *fb_info;
759 struct fb_modelist *modelist; 783 struct fb_modelist *modelist;
760 struct pinctrl *pinctrl; 784 struct pinctrl *pinctrl;
785 int panel_enable;
786 enum of_gpio_flags flags;
761 int i, ret; 787 int i, ret;
762 788
789 if (of_id)
790 pdev->id_entry = of_id->data;
791
763 if (!pdata) { 792 if (!pdata) {
764 dev_err(&pdev->dev, "No platformdata. Giving up\n"); 793 dev_err(&pdev->dev, "No platformdata. Giving up\n");
765 return -ENODEV; 794 return -ENODEV;
@@ -807,6 +836,22 @@ static int __devinit mxsfb_probe(struct platform_device *pdev)
807 goto error_getclock; 836 goto error_getclock;
808 } 837 }
809 838
839 panel_enable = of_get_named_gpio_flags(pdev->dev.of_node,
840 "panel-enable-gpios", 0, &flags);
841 if (gpio_is_valid(panel_enable)) {
842 unsigned long f = GPIOF_OUT_INIT_HIGH;
843 if (flags == OF_GPIO_ACTIVE_LOW)
844 f = GPIOF_OUT_INIT_LOW;
845 ret = devm_gpio_request_one(&pdev->dev, panel_enable,
846 f, "panel-enable");
847 if (ret) {
848 dev_err(&pdev->dev,
849 "failed to request gpio %d: %d\n",
850 panel_enable, ret);
851 goto error_panel_enable;
852 }
853 }
854
810 fb_info->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); 855 fb_info->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL);
811 if (!fb_info->pseudo_palette) { 856 if (!fb_info->pseudo_palette) {
812 ret = -ENOMEM; 857 ret = -ENOMEM;
@@ -854,6 +899,7 @@ error_register:
854error_init_fb: 899error_init_fb:
855 kfree(fb_info->pseudo_palette); 900 kfree(fb_info->pseudo_palette);
856error_pseudo_pallette: 901error_pseudo_pallette:
902error_panel_enable:
857 clk_put(host->clk); 903 clk_put(host->clk);
858error_getclock: 904error_getclock:
859error_getpin: 905error_getpin:
@@ -901,19 +947,6 @@ static void mxsfb_shutdown(struct platform_device *pdev)
901 writel(CTRL_RUN, host->base + LCDC_CTRL + REG_CLR); 947 writel(CTRL_RUN, host->base + LCDC_CTRL + REG_CLR);
902} 948}
903 949
904static struct platform_device_id mxsfb_devtype[] = {
905 {
906 .name = "imx23-fb",
907 .driver_data = MXSFB_V3,
908 }, {
909 .name = "imx28-fb",
910 .driver_data = MXSFB_V4,
911 }, {
912 /* sentinel */
913 }
914};
915MODULE_DEVICE_TABLE(platform, mxsfb_devtype);
916
917static struct platform_driver mxsfb_driver = { 950static struct platform_driver mxsfb_driver = {
918 .probe = mxsfb_probe, 951 .probe = mxsfb_probe,
919 .remove = __devexit_p(mxsfb_remove), 952 .remove = __devexit_p(mxsfb_remove),
@@ -921,6 +954,7 @@ static struct platform_driver mxsfb_driver = {
921 .id_table = mxsfb_devtype, 954 .id_table = mxsfb_devtype,
922 .driver = { 955 .driver = {
923 .name = DRIVER_NAME, 956 .name = DRIVER_NAME,
957 .of_match_table = mxsfb_dt_ids,
924 }, 958 },
925}; 959};
926 960
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 8285d65cd207..02ebfd5f0e65 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -430,6 +430,12 @@ static int omap_wdt_resume(struct platform_device *pdev)
430#define omap_wdt_resume NULL 430#define omap_wdt_resume NULL
431#endif 431#endif
432 432
433static const struct of_device_id omap_wdt_of_match[] = {
434 { .compatible = "ti,omap3-wdt", },
435 {},
436};
437MODULE_DEVICE_TABLE(of, omap_wdt_of_match);
438
433static struct platform_driver omap_wdt_driver = { 439static struct platform_driver omap_wdt_driver = {
434 .probe = omap_wdt_probe, 440 .probe = omap_wdt_probe,
435 .remove = __devexit_p(omap_wdt_remove), 441 .remove = __devexit_p(omap_wdt_remove),
@@ -439,6 +445,7 @@ static struct platform_driver omap_wdt_driver = {
439 .driver = { 445 .driver = {
440 .owner = THIS_MODULE, 446 .owner = THIS_MODULE,
441 .name = "omap_wdt", 447 .name = "omap_wdt",
448 .of_match_table = omap_wdt_of_match,
442 }, 449 },
443}; 450};
444 451