.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Freescale MXS On-Chip OTP driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2015 Stefan Wahren <stefan.wahren@i2se.com> |
---|
5 | 6 | * |
---|
6 | 7 | * Based on the driver from Huang Shijie and Christoph G. Baumann |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License as published by |
---|
10 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
11 | | - * (at your option) any later version. |
---|
12 | | - * |
---|
13 | | - * This program is distributed in the hope that it will be useful, |
---|
14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | | - * GNU General Public License for more details. |
---|
17 | | - * |
---|
18 | 8 | */ |
---|
19 | 9 | #include <linux/clk.h> |
---|
20 | 10 | #include <linux/delay.h> |
---|
.. | .. |
---|
140 | 130 | }; |
---|
141 | 131 | MODULE_DEVICE_TABLE(of, mxs_ocotp_match); |
---|
142 | 132 | |
---|
| 133 | +static void mxs_ocotp_action(void *data) |
---|
| 134 | +{ |
---|
| 135 | + clk_unprepare(data); |
---|
| 136 | +} |
---|
| 137 | + |
---|
143 | 138 | static int mxs_ocotp_probe(struct platform_device *pdev) |
---|
144 | 139 | { |
---|
145 | 140 | struct device *dev = &pdev->dev; |
---|
146 | 141 | const struct mxs_data *data; |
---|
147 | 142 | struct mxs_ocotp *otp; |
---|
148 | | - struct resource *res; |
---|
149 | 143 | const struct of_device_id *match; |
---|
150 | 144 | int ret; |
---|
151 | 145 | |
---|
.. | .. |
---|
157 | 151 | if (!otp) |
---|
158 | 152 | return -ENOMEM; |
---|
159 | 153 | |
---|
160 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
161 | | - otp->base = devm_ioremap_resource(dev, res); |
---|
| 154 | + otp->base = devm_platform_ioremap_resource(pdev, 0); |
---|
162 | 155 | if (IS_ERR(otp->base)) |
---|
163 | 156 | return PTR_ERR(otp->base); |
---|
164 | 157 | |
---|
.. | .. |
---|
172 | 165 | return ret; |
---|
173 | 166 | } |
---|
174 | 167 | |
---|
| 168 | + ret = devm_add_action_or_reset(&pdev->dev, mxs_ocotp_action, otp->clk); |
---|
| 169 | + if (ret) |
---|
| 170 | + return ret; |
---|
| 171 | + |
---|
175 | 172 | data = match->data; |
---|
176 | 173 | |
---|
177 | 174 | ocotp_config.size = data->size; |
---|
178 | 175 | ocotp_config.priv = otp; |
---|
179 | 176 | ocotp_config.dev = dev; |
---|
180 | | - otp->nvmem = nvmem_register(&ocotp_config); |
---|
181 | | - if (IS_ERR(otp->nvmem)) { |
---|
182 | | - ret = PTR_ERR(otp->nvmem); |
---|
183 | | - goto err_clk; |
---|
184 | | - } |
---|
| 177 | + otp->nvmem = devm_nvmem_register(dev, &ocotp_config); |
---|
| 178 | + if (IS_ERR(otp->nvmem)) |
---|
| 179 | + return PTR_ERR(otp->nvmem); |
---|
185 | 180 | |
---|
186 | 181 | platform_set_drvdata(pdev, otp); |
---|
187 | 182 | |
---|
188 | 183 | return 0; |
---|
189 | | - |
---|
190 | | -err_clk: |
---|
191 | | - clk_unprepare(otp->clk); |
---|
192 | | - |
---|
193 | | - return ret; |
---|
194 | | -} |
---|
195 | | - |
---|
196 | | -static int mxs_ocotp_remove(struct platform_device *pdev) |
---|
197 | | -{ |
---|
198 | | - struct mxs_ocotp *otp = platform_get_drvdata(pdev); |
---|
199 | | - |
---|
200 | | - clk_unprepare(otp->clk); |
---|
201 | | - |
---|
202 | | - return nvmem_unregister(otp->nvmem); |
---|
203 | 184 | } |
---|
204 | 185 | |
---|
205 | 186 | static struct platform_driver mxs_ocotp_driver = { |
---|
206 | 187 | .probe = mxs_ocotp_probe, |
---|
207 | | - .remove = mxs_ocotp_remove, |
---|
208 | 188 | .driver = { |
---|
209 | 189 | .name = "mxs-ocotp", |
---|
210 | 190 | .of_match_table = mxs_ocotp_match, |
---|
.. | .. |
---|
212 | 192 | }; |
---|
213 | 193 | |
---|
214 | 194 | module_platform_driver(mxs_ocotp_driver); |
---|
215 | | -MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>"); |
---|
| 195 | +MODULE_AUTHOR("Stefan Wahren <wahrenst@gmx.net"); |
---|
216 | 196 | MODULE_DESCRIPTION("driver for OCOTP in i.MX23/i.MX28"); |
---|
217 | 197 | MODULE_LICENSE("GPL v2"); |
---|