blob: e5e176b3f561a2a41502174d2707cc4df8ba0348 [file] [log] [blame]
Matt Wagantallc2bbdc32012-03-21 19:44:50 -07001/*
2 * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/init.h>
15#include <linux/module.h>
16#include <linux/platform_device.h>
17#include <linux/io.h>
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070018#include <linux/err.h>
19#include <linux/of.h>
Matt Wagantalld41ce772012-05-10 23:16:41 -070020#include <linux/clk.h>
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070021
22#include "peripheral-loader.h"
23#include "pil-q6v5.h"
24
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070025#define QDSP6SS_RST_EVB 0x010
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070026
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070027static int pil_lpass_shutdown(struct pil_desc *pil)
28{
29 struct q6v5_data *drv = dev_get_drvdata(pil->dev);
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070030
Matt Wagantallb7747992012-05-11 19:37:51 -070031 pil_q6v5_halt_axi_port(pil, drv->axi_halt_base);
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070032
Matt Wagantalld41ce772012-05-10 23:16:41 -070033 /*
34 * If the shutdown function is called before the reset function, clocks
35 * will not be enabled yet. Enable them here so that register writes
36 * performed during the shutdown succeed.
37 */
38 if (drv->is_booted == false)
39 pil_q6v5_enable_clks(pil);
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070040
41 pil_q6v5_shutdown(pil);
Matt Wagantalld41ce772012-05-10 23:16:41 -070042 pil_q6v5_disable_clks(pil);
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070043
Matt Wagantalld41ce772012-05-10 23:16:41 -070044 drv->is_booted = false;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070045
46 return 0;
47}
48
49static int pil_lpass_reset(struct pil_desc *pil)
50{
51 struct q6v5_data *drv = dev_get_drvdata(pil->dev);
Matt Wagantalld41ce772012-05-10 23:16:41 -070052 int ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070053
Matt Wagantalld41ce772012-05-10 23:16:41 -070054 ret = pil_q6v5_enable_clks(pil);
55 if (ret)
56 return ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070057
58 /* Program Image Address */
59 writel_relaxed(((drv->start_addr >> 4) & 0x0FFFFFF0),
60 drv->reg_base + QDSP6SS_RST_EVB);
61
Matt Wagantalld41ce772012-05-10 23:16:41 -070062 ret = pil_q6v5_reset(pil);
63 if (ret) {
64 pil_q6v5_disable_clks(pil);
65 return ret;
66 }
67
68 drv->is_booted = true;
69
70 return 0;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070071}
72
73static struct pil_reset_ops pil_lpass_ops = {
74 .init_image = pil_q6v5_init_image,
75 .proxy_vote = pil_q6v5_make_proxy_votes,
76 .proxy_unvote = pil_q6v5_remove_proxy_votes,
77 .auth_and_reset = pil_lpass_reset,
78 .shutdown = pil_lpass_shutdown,
79};
80
81static int __devinit pil_lpass_driver_probe(struct platform_device *pdev)
82{
83 struct q6v5_data *drv;
84 struct pil_desc *desc;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070085
86 desc = pil_q6v5_init(pdev);
Matt Wagantall55252f12012-05-02 18:02:54 -070087 if (IS_ERR(desc))
88 return PTR_ERR(desc);
89
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070090 drv = platform_get_drvdata(pdev);
Matt Wagantall55252f12012-05-02 18:02:54 -070091 if (drv == NULL)
92 return -ENODEV;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070093
94 desc->ops = &pil_lpass_ops;
95 desc->owner = THIS_MODULE;
96
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070097 drv->pil = msm_pil_register(desc);
98 if (IS_ERR(drv->pil))
99 return PTR_ERR(drv->pil);
100
101 return 0;
102}
103
104static int __devexit pil_lpass_driver_exit(struct platform_device *pdev)
105{
106 struct q6v5_data *drv = platform_get_drvdata(pdev);
107 msm_pil_unregister(drv->pil);
108 return 0;
109}
110
111static struct of_device_id lpass_match_table[] = {
112 { .compatible = "qcom,pil-q6v5-lpass" },
113 {}
114};
115
116static struct platform_driver pil_lpass_driver = {
117 .probe = pil_lpass_driver_probe,
118 .remove = __devexit_p(pil_lpass_driver_exit),
119 .driver = {
120 .name = "pil-q6v5-lpass",
121 .of_match_table = lpass_match_table,
122 .owner = THIS_MODULE,
123 },
124};
125
126static int __init pil_lpass_init(void)
127{
128 return platform_driver_register(&pil_lpass_driver);
129}
130module_init(pil_lpass_init);
131
132static void __exit pil_lpass_exit(void)
133{
134 platform_driver_unregister(&pil_lpass_driver);
135}
136module_exit(pil_lpass_exit);
137
138MODULE_DESCRIPTION("Support for booting low-power audio subsystems with QDSP6v5 (Hexagon) processors");
139MODULE_LICENSE("GPL v2");