20 #include <linux/device.h>
22 #include <linux/module.h>
27 #include <linux/slab.h>
33 #define DRV_NAME "tegra30-ahub"
42 static inline u32 tegra30_apbif_read(
u32 reg)
54 static int tegra30_ahub_runtime_suspend(
struct device *
dev)
76 static int tegra30_ahub_runtime_resume(
struct device *
dev)
82 dev_err(dev,
"clk_enable d_audio failed: %d\n", ret);
85 ret = clk_prepare_enable(ahub->
clk_apbif);
87 dev_err(dev,
"clk_enable apbif failed: %d\n", ret);
99 unsigned long *fiforeg,
100 unsigned long *reqsel)
119 val = tegra30_apbif_read(reg);
125 tegra30_apbif_write(reg, val);
135 tegra30_apbif_write(reg, val);
148 val = tegra30_apbif_read(reg);
150 tegra30_apbif_write(reg, val);
163 val = tegra30_apbif_read(reg);
165 tegra30_apbif_write(reg, val);
182 unsigned long *fiforeg,
183 unsigned long *reqsel)
202 val = tegra30_apbif_read(reg);
208 tegra30_apbif_write(reg, val);
218 tegra30_apbif_write(reg, val);
231 val = tegra30_apbif_read(reg);
233 tegra30_apbif_write(reg, val);
246 val = tegra30_apbif_read(reg);
248 tegra30_apbif_write(reg, val);
272 tegra30_audio_write(reg, 1 << txcif);
285 tegra30_audio_write(reg, 0);
304 OF_DEV_AUXDATA(
"nvidia,tegra30-i2s", 0x70080300,
"tegra30-i2s.0",
NULL),
305 OF_DEV_AUXDATA(
"nvidia,tegra30-i2s", 0x70080400,
"tegra30-i2s.1",
NULL),
306 OF_DEV_AUXDATA(
"nvidia,tegra30-i2s", 0x70080500,
"tegra30-i2s.2",
NULL),
307 OF_DEV_AUXDATA(
"nvidia,tegra30-i2s", 0x70080600,
"tegra30-i2s.3",
NULL),
308 OF_DEV_AUXDATA(
"nvidia,tegra30-i2s", 0x70080700,
"tegra30-i2s.4",
NULL),
312 #define LAST_REG(name) \
313 (TEGRA30_AHUB_##name + \
314 (TEGRA30_AHUB_##name##_STRIDE * TEGRA30_AHUB_##name##_COUNT) - 4)
316 #define REG_IN_ARRAY(reg, name) \
317 ((reg >= TEGRA30_AHUB_##name) && \
318 (reg <= LAST_REG(name) && \
319 (!((reg - TEGRA30_AHUB_##name) % TEGRA30_AHUB_##name##_STRIDE))))
321 static bool tegra30_ahub_apbif_wr_rd_reg(
struct device *dev,
unsigned int reg)
363 static bool tegra30_ahub_apbif_volatile_reg(
struct device *dev,
395 static bool tegra30_ahub_apbif_precious_reg(
struct device *dev,
405 static const struct regmap_config tegra30_ahub_apbif_regmap_config = {
411 .writeable_reg = tegra30_ahub_apbif_wr_rd_reg,
412 .readable_reg = tegra30_ahub_apbif_wr_rd_reg,
413 .volatile_reg = tegra30_ahub_apbif_volatile_reg,
414 .precious_reg = tegra30_ahub_apbif_precious_reg,
418 static bool tegra30_ahub_ahub_wr_rd_reg(
struct device *dev,
unsigned int reg)
426 static const struct regmap_config tegra30_ahub_ahub_regmap_config = {
432 .writeable_reg = tegra30_ahub_ahub_wr_rd_reg,
433 .readable_reg = tegra30_ahub_ahub_wr_rd_reg,
443 void __iomem *regs_apbif, *regs_ahub;
454 for (i = 0; i <
ARRAY_SIZE(configlink_clocks); i++) {
458 configlink_clocks[i]);
469 dev_err(&pdev->
dev,
"Can't allocate tegra30_ahub\n");
479 dev_err(&pdev->
dev,
"Can't retrieve ahub d_audio clock\n");
486 dev_err(&pdev->
dev,
"Can't retrieve ahub apbif clock\n");
488 goto err_clk_put_d_audio;
492 "nvidia,dma-request-selector",
495 "Missing property nvidia,dma-request-selector\n");
497 goto err_clk_put_d_audio;
503 dev_err(&pdev->
dev,
"No apbif memory resource\n");
505 goto err_clk_put_apbif;
511 dev_err(&pdev->
dev,
"request region apbif failed\n");
513 goto err_clk_put_apbif;
518 resource_size(res0));
520 dev_err(&pdev->
dev,
"ioremap apbif failed\n");
522 goto err_clk_put_apbif;
526 &tegra30_ahub_apbif_regmap_config);
528 dev_err(&pdev->
dev,
"apbif regmap init failed\n");
530 goto err_clk_put_apbif;
536 dev_err(&pdev->
dev,
"No ahub memory resource\n");
538 goto err_clk_put_apbif;
544 dev_err(&pdev->
dev,
"request region ahub failed\n");
546 goto err_clk_put_apbif;
550 resource_size(res1));
554 goto err_clk_put_apbif;
558 &tegra30_ahub_ahub_regmap_config);
560 dev_err(&pdev->
dev,
"ahub regmap init failed\n");
562 goto err_clk_put_apbif;
567 if (!pm_runtime_enabled(&pdev->
dev)) {
568 ret = tegra30_ahub_runtime_resume(&pdev->
dev);
573 of_platform_populate(pdev->
dev.of_node,
NULL, ahub_auxdata,
579 pm_runtime_disable(&pdev->
dev);
594 pm_runtime_disable(&pdev->
dev);
595 if (!pm_runtime_status_suspended(&pdev->
dev))
596 tegra30_ahub_runtime_suspend(&pdev->
dev);
606 static const struct of_device_id tegra30_ahub_of_match[] __devinitconst = {
611 static const struct dev_pm_ops tegra30_ahub_pm_ops __devinitconst = {
613 tegra30_ahub_runtime_resume,
NULL)
617 .probe = tegra30_ahub_probe,
622 .of_match_table = tegra30_ahub_of_match,
623 .pm = &tegra30_ahub_pm_ops,