1 /* OMAP SSI driver. 2 * 3 * Copyright (C) 2010 Nokia Corporation. All rights reserved. 4 * Copyright (C) 2014 Sebastian Reichel <sre@kernel.org> 5 * 6 * Contact: Carlos Chinea <carlos.chinea@nokia.com> 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * version 2 as published by the Free Software Foundation. 11 * 12 * This program is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 * 02110-1301 USA 21 */ 22 23 #include <linux/compiler.h> 24 #include <linux/err.h> 25 #include <linux/ioport.h> 26 #include <linux/io.h> 27 #include <linux/clk.h> 28 #include <linux/device.h> 29 #include <linux/platform_device.h> 30 #include <linux/dma-mapping.h> 31 #include <linux/dmaengine.h> 32 #include <linux/delay.h> 33 #include <linux/seq_file.h> 34 #include <linux/scatterlist.h> 35 #include <linux/interrupt.h> 36 #include <linux/spinlock.h> 37 #include <linux/debugfs.h> 38 #include <linux/pinctrl/consumer.h> 39 #include <linux/pm_runtime.h> 40 #include <linux/of_platform.h> 41 #include <linux/hsi/hsi.h> 42 #include <linux/idr.h> 43 44 #include "omap_ssi_regs.h" 45 #include "omap_ssi.h" 46 47 /* For automatically allocated device IDs */ 48 static DEFINE_IDA(platform_omap_ssi_ida); 49 50 #ifdef CONFIG_DEBUG_FS 51 static int ssi_regs_show(struct seq_file *m, void *p __maybe_unused) 52 { 53 struct hsi_controller *ssi = m->private; 54 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 55 void __iomem *sys = omap_ssi->sys; 56 57 pm_runtime_get_sync(ssi->device.parent); 58 seq_printf(m, "REVISION\t: 0x%08x\n", readl(sys + SSI_REVISION_REG)); 59 seq_printf(m, "SYSCONFIG\t: 0x%08x\n", readl(sys + SSI_SYSCONFIG_REG)); 60 seq_printf(m, "SYSSTATUS\t: 0x%08x\n", readl(sys + SSI_SYSSTATUS_REG)); 61 pm_runtime_put(ssi->device.parent); 62 63 return 0; 64 } 65 66 static int ssi_gdd_regs_show(struct seq_file *m, void *p __maybe_unused) 67 { 68 struct hsi_controller *ssi = m->private; 69 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 70 void __iomem *gdd = omap_ssi->gdd; 71 void __iomem *sys = omap_ssi->sys; 72 int lch; 73 74 pm_runtime_get_sync(ssi->device.parent); 75 76 seq_printf(m, "GDD_MPU_STATUS\t: 0x%08x\n", 77 readl(sys + SSI_GDD_MPU_IRQ_STATUS_REG)); 78 seq_printf(m, "GDD_MPU_ENABLE\t: 0x%08x\n\n", 79 readl(sys + SSI_GDD_MPU_IRQ_ENABLE_REG)); 80 seq_printf(m, "HW_ID\t\t: 0x%08x\n", 81 readl(gdd + SSI_GDD_HW_ID_REG)); 82 seq_printf(m, "PPORT_ID\t: 0x%08x\n", 83 readl(gdd + SSI_GDD_PPORT_ID_REG)); 84 seq_printf(m, "MPORT_ID\t: 0x%08x\n", 85 readl(gdd + SSI_GDD_MPORT_ID_REG)); 86 seq_printf(m, "TEST\t\t: 0x%08x\n", 87 readl(gdd + SSI_GDD_TEST_REG)); 88 seq_printf(m, "GCR\t\t: 0x%08x\n", 89 readl(gdd + SSI_GDD_GCR_REG)); 90 91 for (lch = 0; lch < SSI_MAX_GDD_LCH; lch++) { 92 seq_printf(m, "\nGDD LCH %d\n=========\n", lch); 93 seq_printf(m, "CSDP\t\t: 0x%04x\n", 94 readw(gdd + SSI_GDD_CSDP_REG(lch))); 95 seq_printf(m, "CCR\t\t: 0x%04x\n", 96 readw(gdd + SSI_GDD_CCR_REG(lch))); 97 seq_printf(m, "CICR\t\t: 0x%04x\n", 98 readw(gdd + SSI_GDD_CICR_REG(lch))); 99 seq_printf(m, "CSR\t\t: 0x%04x\n", 100 readw(gdd + SSI_GDD_CSR_REG(lch))); 101 seq_printf(m, "CSSA\t\t: 0x%08x\n", 102 readl(gdd + SSI_GDD_CSSA_REG(lch))); 103 seq_printf(m, "CDSA\t\t: 0x%08x\n", 104 readl(gdd + SSI_GDD_CDSA_REG(lch))); 105 seq_printf(m, "CEN\t\t: 0x%04x\n", 106 readw(gdd + SSI_GDD_CEN_REG(lch))); 107 seq_printf(m, "CSAC\t\t: 0x%04x\n", 108 readw(gdd + SSI_GDD_CSAC_REG(lch))); 109 seq_printf(m, "CDAC\t\t: 0x%04x\n", 110 readw(gdd + SSI_GDD_CDAC_REG(lch))); 111 seq_printf(m, "CLNK_CTRL\t: 0x%04x\n", 112 readw(gdd + SSI_GDD_CLNK_CTRL_REG(lch))); 113 } 114 115 pm_runtime_put(ssi->device.parent); 116 117 return 0; 118 } 119 120 DEFINE_SHOW_ATTRIBUTE(ssi_regs); 121 DEFINE_SHOW_ATTRIBUTE(ssi_gdd_regs); 122 123 static int ssi_debug_add_ctrl(struct hsi_controller *ssi) 124 { 125 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 126 struct dentry *dir; 127 128 /* SSI controller */ 129 omap_ssi->dir = debugfs_create_dir(dev_name(&ssi->device), NULL); 130 if (!omap_ssi->dir) 131 return -ENOMEM; 132 133 debugfs_create_file("regs", S_IRUGO, omap_ssi->dir, ssi, 134 &ssi_regs_fops); 135 /* SSI GDD (DMA) */ 136 dir = debugfs_create_dir("gdd", omap_ssi->dir); 137 if (!dir) 138 goto rback; 139 debugfs_create_file("regs", S_IRUGO, dir, ssi, &ssi_gdd_regs_fops); 140 141 return 0; 142 rback: 143 debugfs_remove_recursive(omap_ssi->dir); 144 145 return -ENOMEM; 146 } 147 148 static void ssi_debug_remove_ctrl(struct hsi_controller *ssi) 149 { 150 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 151 152 debugfs_remove_recursive(omap_ssi->dir); 153 } 154 #endif /* CONFIG_DEBUG_FS */ 155 156 /* 157 * FIXME: Horrible HACK needed until we remove the useless wakeline test 158 * in the CMT. To be removed !!!! 159 */ 160 void ssi_waketest(struct hsi_client *cl, unsigned int enable) 161 { 162 struct hsi_port *port = hsi_get_port(cl); 163 struct omap_ssi_port *omap_port = hsi_port_drvdata(port); 164 struct hsi_controller *ssi = to_hsi_controller(port->device.parent); 165 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 166 167 omap_port->wktest = !!enable; 168 if (omap_port->wktest) { 169 pm_runtime_get_sync(ssi->device.parent); 170 writel_relaxed(SSI_WAKE(0), 171 omap_ssi->sys + SSI_SET_WAKE_REG(port->num)); 172 } else { 173 writel_relaxed(SSI_WAKE(0), 174 omap_ssi->sys + SSI_CLEAR_WAKE_REG(port->num)); 175 pm_runtime_put(ssi->device.parent); 176 } 177 } 178 EXPORT_SYMBOL_GPL(ssi_waketest); 179 180 static void ssi_gdd_complete(struct hsi_controller *ssi, unsigned int lch) 181 { 182 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 183 struct hsi_msg *msg = omap_ssi->gdd_trn[lch].msg; 184 struct hsi_port *port = to_hsi_port(msg->cl->device.parent); 185 struct omap_ssi_port *omap_port = hsi_port_drvdata(port); 186 unsigned int dir; 187 u32 csr; 188 u32 val; 189 190 spin_lock(&omap_ssi->lock); 191 192 val = readl(omap_ssi->sys + SSI_GDD_MPU_IRQ_ENABLE_REG); 193 val &= ~SSI_GDD_LCH(lch); 194 writel_relaxed(val, omap_ssi->sys + SSI_GDD_MPU_IRQ_ENABLE_REG); 195 196 if (msg->ttype == HSI_MSG_READ) { 197 dir = DMA_FROM_DEVICE; 198 val = SSI_DATAAVAILABLE(msg->channel); 199 pm_runtime_put(omap_port->pdev); 200 } else { 201 dir = DMA_TO_DEVICE; 202 val = SSI_DATAACCEPT(msg->channel); 203 /* Keep clocks reference for write pio event */ 204 } 205 dma_unmap_sg(&ssi->device, msg->sgt.sgl, msg->sgt.nents, dir); 206 csr = readw(omap_ssi->gdd + SSI_GDD_CSR_REG(lch)); 207 omap_ssi->gdd_trn[lch].msg = NULL; /* release GDD lch */ 208 dev_dbg(&port->device, "DMA completed ch %d ttype %d\n", 209 msg->channel, msg->ttype); 210 spin_unlock(&omap_ssi->lock); 211 if (csr & SSI_CSR_TOUR) { /* Timeout error */ 212 msg->status = HSI_STATUS_ERROR; 213 msg->actual_len = 0; 214 spin_lock(&omap_port->lock); 215 list_del(&msg->link); /* Dequeue msg */ 216 spin_unlock(&omap_port->lock); 217 218 list_add_tail(&msg->link, &omap_port->errqueue); 219 schedule_delayed_work(&omap_port->errqueue_work, 0); 220 return; 221 } 222 spin_lock(&omap_port->lock); 223 val |= readl(omap_ssi->sys + SSI_MPU_ENABLE_REG(port->num, 0)); 224 writel_relaxed(val, omap_ssi->sys + SSI_MPU_ENABLE_REG(port->num, 0)); 225 spin_unlock(&omap_port->lock); 226 227 msg->status = HSI_STATUS_COMPLETED; 228 msg->actual_len = sg_dma_len(msg->sgt.sgl); 229 } 230 231 static void ssi_gdd_tasklet(unsigned long dev) 232 { 233 struct hsi_controller *ssi = (struct hsi_controller *)dev; 234 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 235 void __iomem *sys = omap_ssi->sys; 236 unsigned int lch; 237 u32 status_reg; 238 239 pm_runtime_get(ssi->device.parent); 240 241 if (!pm_runtime_active(ssi->device.parent)) { 242 dev_warn(ssi->device.parent, "ssi_gdd_tasklet called without runtime PM!\n"); 243 pm_runtime_put(ssi->device.parent); 244 return; 245 } 246 247 status_reg = readl(sys + SSI_GDD_MPU_IRQ_STATUS_REG); 248 for (lch = 0; lch < SSI_MAX_GDD_LCH; lch++) { 249 if (status_reg & SSI_GDD_LCH(lch)) 250 ssi_gdd_complete(ssi, lch); 251 } 252 writel_relaxed(status_reg, sys + SSI_GDD_MPU_IRQ_STATUS_REG); 253 status_reg = readl(sys + SSI_GDD_MPU_IRQ_STATUS_REG); 254 255 pm_runtime_put(ssi->device.parent); 256 257 if (status_reg) 258 tasklet_hi_schedule(&omap_ssi->gdd_tasklet); 259 else 260 enable_irq(omap_ssi->gdd_irq); 261 262 } 263 264 static irqreturn_t ssi_gdd_isr(int irq, void *ssi) 265 { 266 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 267 268 tasklet_hi_schedule(&omap_ssi->gdd_tasklet); 269 disable_irq_nosync(irq); 270 271 return IRQ_HANDLED; 272 } 273 274 static unsigned long ssi_get_clk_rate(struct hsi_controller *ssi) 275 { 276 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 277 unsigned long rate = clk_get_rate(omap_ssi->fck); 278 return rate; 279 } 280 281 static int ssi_clk_event(struct notifier_block *nb, unsigned long event, 282 void *data) 283 { 284 struct omap_ssi_controller *omap_ssi = container_of(nb, 285 struct omap_ssi_controller, fck_nb); 286 struct hsi_controller *ssi = to_hsi_controller(omap_ssi->dev); 287 struct clk_notifier_data *clk_data = data; 288 struct omap_ssi_port *omap_port; 289 int i; 290 291 switch (event) { 292 case PRE_RATE_CHANGE: 293 dev_dbg(&ssi->device, "pre rate change\n"); 294 295 for (i = 0; i < ssi->num_ports; i++) { 296 omap_port = omap_ssi->port[i]; 297 298 if (!omap_port) 299 continue; 300 301 /* Workaround for SWBREAK + CAwake down race in CMT */ 302 disable_irq(omap_port->wake_irq); 303 304 /* stop all ssi communication */ 305 pinctrl_pm_select_idle_state(omap_port->pdev); 306 udelay(1); /* wait for racing frames */ 307 } 308 309 break; 310 case ABORT_RATE_CHANGE: 311 dev_dbg(&ssi->device, "abort rate change\n"); 312 /* Fall through */ 313 case POST_RATE_CHANGE: 314 dev_dbg(&ssi->device, "post rate change (%lu -> %lu)\n", 315 clk_data->old_rate, clk_data->new_rate); 316 omap_ssi->fck_rate = DIV_ROUND_CLOSEST(clk_data->new_rate, 1000); /* kHz */ 317 318 for (i = 0; i < ssi->num_ports; i++) { 319 omap_port = omap_ssi->port[i]; 320 321 if (!omap_port) 322 continue; 323 324 omap_ssi_port_update_fclk(ssi, omap_port); 325 326 /* resume ssi communication */ 327 pinctrl_pm_select_default_state(omap_port->pdev); 328 enable_irq(omap_port->wake_irq); 329 } 330 331 break; 332 default: 333 break; 334 } 335 336 return NOTIFY_DONE; 337 } 338 339 static int ssi_get_iomem(struct platform_device *pd, 340 const char *name, void __iomem **pbase, dma_addr_t *phy) 341 { 342 struct resource *mem; 343 void __iomem *base; 344 struct hsi_controller *ssi = platform_get_drvdata(pd); 345 346 mem = platform_get_resource_byname(pd, IORESOURCE_MEM, name); 347 base = devm_ioremap_resource(&ssi->device, mem); 348 if (IS_ERR(base)) 349 return PTR_ERR(base); 350 351 *pbase = base; 352 353 if (phy) 354 *phy = mem->start; 355 356 return 0; 357 } 358 359 static int ssi_add_controller(struct hsi_controller *ssi, 360 struct platform_device *pd) 361 { 362 struct omap_ssi_controller *omap_ssi; 363 int err; 364 365 omap_ssi = devm_kzalloc(&ssi->device, sizeof(*omap_ssi), GFP_KERNEL); 366 if (!omap_ssi) 367 return -ENOMEM; 368 369 err = ida_simple_get(&platform_omap_ssi_ida, 0, 0, GFP_KERNEL); 370 if (err < 0) 371 goto out_err; 372 ssi->id = err; 373 374 ssi->owner = THIS_MODULE; 375 ssi->device.parent = &pd->dev; 376 dev_set_name(&ssi->device, "ssi%d", ssi->id); 377 hsi_controller_set_drvdata(ssi, omap_ssi); 378 omap_ssi->dev = &ssi->device; 379 err = ssi_get_iomem(pd, "sys", &omap_ssi->sys, NULL); 380 if (err < 0) 381 goto out_err; 382 err = ssi_get_iomem(pd, "gdd", &omap_ssi->gdd, NULL); 383 if (err < 0) 384 goto out_err; 385 err = platform_get_irq_byname(pd, "gdd_mpu"); 386 if (err < 0) { 387 dev_err(&pd->dev, "GDD IRQ resource missing\n"); 388 goto out_err; 389 } 390 omap_ssi->gdd_irq = err; 391 tasklet_init(&omap_ssi->gdd_tasklet, ssi_gdd_tasklet, 392 (unsigned long)ssi); 393 err = devm_request_irq(&ssi->device, omap_ssi->gdd_irq, ssi_gdd_isr, 394 0, "gdd_mpu", ssi); 395 if (err < 0) { 396 dev_err(&ssi->device, "Request GDD IRQ %d failed (%d)", 397 omap_ssi->gdd_irq, err); 398 goto out_err; 399 } 400 401 omap_ssi->port = devm_kcalloc(&ssi->device, ssi->num_ports, 402 sizeof(*omap_ssi->port), GFP_KERNEL); 403 if (!omap_ssi->port) { 404 err = -ENOMEM; 405 goto out_err; 406 } 407 408 omap_ssi->fck = devm_clk_get(&ssi->device, "ssi_ssr_fck"); 409 if (IS_ERR(omap_ssi->fck)) { 410 dev_err(&pd->dev, "Could not acquire clock \"ssi_ssr_fck\": %li\n", 411 PTR_ERR(omap_ssi->fck)); 412 err = -ENODEV; 413 goto out_err; 414 } 415 416 omap_ssi->fck_nb.notifier_call = ssi_clk_event; 417 omap_ssi->fck_nb.priority = INT_MAX; 418 clk_notifier_register(omap_ssi->fck, &omap_ssi->fck_nb); 419 420 /* TODO: find register, which can be used to detect context loss */ 421 omap_ssi->get_loss = NULL; 422 423 omap_ssi->max_speed = UINT_MAX; 424 spin_lock_init(&omap_ssi->lock); 425 err = hsi_register_controller(ssi); 426 427 if (err < 0) 428 goto out_err; 429 430 return 0; 431 432 out_err: 433 ida_simple_remove(&platform_omap_ssi_ida, ssi->id); 434 return err; 435 } 436 437 static int ssi_hw_init(struct hsi_controller *ssi) 438 { 439 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 440 int err; 441 442 err = pm_runtime_get_sync(ssi->device.parent); 443 if (err < 0) { 444 dev_err(&ssi->device, "runtime PM failed %d\n", err); 445 return err; 446 } 447 /* Resetting GDD */ 448 writel_relaxed(SSI_SWRESET, omap_ssi->gdd + SSI_GDD_GRST_REG); 449 /* Get FCK rate in kHz */ 450 omap_ssi->fck_rate = DIV_ROUND_CLOSEST(ssi_get_clk_rate(ssi), 1000); 451 dev_dbg(&ssi->device, "SSI fck rate %lu kHz\n", omap_ssi->fck_rate); 452 453 writel_relaxed(SSI_CLK_AUTOGATING_ON, omap_ssi->sys + SSI_GDD_GCR_REG); 454 omap_ssi->gdd_gcr = SSI_CLK_AUTOGATING_ON; 455 pm_runtime_put_sync(ssi->device.parent); 456 457 return 0; 458 } 459 460 static void ssi_remove_controller(struct hsi_controller *ssi) 461 { 462 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 463 int id = ssi->id; 464 tasklet_kill(&omap_ssi->gdd_tasklet); 465 hsi_unregister_controller(ssi); 466 clk_notifier_unregister(omap_ssi->fck, &omap_ssi->fck_nb); 467 ida_simple_remove(&platform_omap_ssi_ida, id); 468 } 469 470 static inline int ssi_of_get_available_ports_count(const struct device_node *np) 471 { 472 struct device_node *child; 473 int num = 0; 474 475 for_each_available_child_of_node(np, child) 476 if (of_device_is_compatible(child, "ti,omap3-ssi-port")) 477 num++; 478 479 return num; 480 } 481 482 static int ssi_remove_ports(struct device *dev, void *c) 483 { 484 struct platform_device *pdev = to_platform_device(dev); 485 486 if (!dev->of_node) 487 return 0; 488 489 of_node_clear_flag(dev->of_node, OF_POPULATED); 490 of_device_unregister(pdev); 491 492 return 0; 493 } 494 495 static int ssi_probe(struct platform_device *pd) 496 { 497 struct platform_device *childpdev; 498 struct device_node *np = pd->dev.of_node; 499 struct device_node *child; 500 struct hsi_controller *ssi; 501 int err; 502 int num_ports; 503 504 if (!np) { 505 dev_err(&pd->dev, "missing device tree data\n"); 506 return -EINVAL; 507 } 508 509 num_ports = ssi_of_get_available_ports_count(np); 510 511 ssi = hsi_alloc_controller(num_ports, GFP_KERNEL); 512 if (!ssi) { 513 dev_err(&pd->dev, "No memory for controller\n"); 514 return -ENOMEM; 515 } 516 517 platform_set_drvdata(pd, ssi); 518 519 err = ssi_add_controller(ssi, pd); 520 if (err < 0) 521 goto out1; 522 523 pm_runtime_enable(&pd->dev); 524 525 err = ssi_hw_init(ssi); 526 if (err < 0) 527 goto out2; 528 #ifdef CONFIG_DEBUG_FS 529 err = ssi_debug_add_ctrl(ssi); 530 if (err < 0) 531 goto out2; 532 #endif 533 534 for_each_available_child_of_node(np, child) { 535 if (!of_device_is_compatible(child, "ti,omap3-ssi-port")) 536 continue; 537 538 childpdev = of_platform_device_create(child, NULL, &pd->dev); 539 if (!childpdev) { 540 err = -ENODEV; 541 dev_err(&pd->dev, "failed to create ssi controller port\n"); 542 goto out3; 543 } 544 } 545 546 dev_info(&pd->dev, "ssi controller %d initialized (%d ports)!\n", 547 ssi->id, num_ports); 548 return err; 549 out3: 550 device_for_each_child(&pd->dev, NULL, ssi_remove_ports); 551 out2: 552 ssi_remove_controller(ssi); 553 out1: 554 platform_set_drvdata(pd, NULL); 555 pm_runtime_disable(&pd->dev); 556 557 return err; 558 } 559 560 static int ssi_remove(struct platform_device *pd) 561 { 562 struct hsi_controller *ssi = platform_get_drvdata(pd); 563 564 /* cleanup of of_platform_populate() call */ 565 device_for_each_child(&pd->dev, NULL, ssi_remove_ports); 566 567 #ifdef CONFIG_DEBUG_FS 568 ssi_debug_remove_ctrl(ssi); 569 #endif 570 ssi_remove_controller(ssi); 571 platform_set_drvdata(pd, NULL); 572 573 pm_runtime_disable(&pd->dev); 574 575 return 0; 576 } 577 578 #ifdef CONFIG_PM 579 static int omap_ssi_runtime_suspend(struct device *dev) 580 { 581 struct hsi_controller *ssi = dev_get_drvdata(dev); 582 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 583 584 dev_dbg(dev, "runtime suspend!\n"); 585 586 if (omap_ssi->get_loss) 587 omap_ssi->loss_count = 588 omap_ssi->get_loss(ssi->device.parent); 589 590 return 0; 591 } 592 593 static int omap_ssi_runtime_resume(struct device *dev) 594 { 595 struct hsi_controller *ssi = dev_get_drvdata(dev); 596 struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); 597 598 dev_dbg(dev, "runtime resume!\n"); 599 600 if ((omap_ssi->get_loss) && (omap_ssi->loss_count == 601 omap_ssi->get_loss(ssi->device.parent))) 602 return 0; 603 604 writel_relaxed(omap_ssi->gdd_gcr, omap_ssi->gdd + SSI_GDD_GCR_REG); 605 606 return 0; 607 } 608 609 static const struct dev_pm_ops omap_ssi_pm_ops = { 610 SET_RUNTIME_PM_OPS(omap_ssi_runtime_suspend, omap_ssi_runtime_resume, 611 NULL) 612 }; 613 614 #define DEV_PM_OPS (&omap_ssi_pm_ops) 615 #else 616 #define DEV_PM_OPS NULL 617 #endif 618 619 #ifdef CONFIG_OF 620 static const struct of_device_id omap_ssi_of_match[] = { 621 { .compatible = "ti,omap3-ssi", }, 622 {}, 623 }; 624 MODULE_DEVICE_TABLE(of, omap_ssi_of_match); 625 #else 626 #define omap_ssi_of_match NULL 627 #endif 628 629 static struct platform_driver ssi_pdriver = { 630 .probe = ssi_probe, 631 .remove = ssi_remove, 632 .driver = { 633 .name = "omap_ssi", 634 .pm = DEV_PM_OPS, 635 .of_match_table = omap_ssi_of_match, 636 }, 637 }; 638 639 static int __init ssi_init(void) { 640 int ret; 641 642 ret = platform_driver_register(&ssi_pdriver); 643 if (ret) 644 return ret; 645 646 return platform_driver_register(&ssi_port_pdriver); 647 } 648 module_init(ssi_init); 649 650 static void __exit ssi_exit(void) { 651 platform_driver_unregister(&ssi_port_pdriver); 652 platform_driver_unregister(&ssi_pdriver); 653 } 654 module_exit(ssi_exit); 655 656 MODULE_ALIAS("platform:omap_ssi"); 657 MODULE_AUTHOR("Carlos Chinea <carlos.chinea@nokia.com>"); 658 MODULE_AUTHOR("Sebastian Reichel <sre@kernel.org>"); 659 MODULE_DESCRIPTION("Synchronous Serial Interface Driver"); 660 MODULE_LICENSE("GPL v2"); 661