14
14
#include <linux/pm_opp.h>
15
15
#include <linux/platform_device.h>
16
16
#include <linux/regulator/consumer.h>
17
+ #include <linux/mfd/syscon.h>
18
+ #include <linux/regmap.h>
17
19
18
20
#define PU_SOC_VOLTAGE_NORMAL 1250000
19
21
#define PU_SOC_VOLTAGE_HIGH 1275000
@@ -225,8 +227,6 @@ static void imx6x_disable_freq_in_opp(struct device *dev, unsigned long freq)
225
227
226
228
static int imx6q_opp_check_speed_grading (struct device * dev )
227
229
{
228
- struct device_node * np ;
229
- void __iomem * base ;
230
230
u32 val ;
231
231
int ret ;
232
232
@@ -235,16 +235,11 @@ static int imx6q_opp_check_speed_grading(struct device *dev)
235
235
if (ret )
236
236
return ret ;
237
237
} else {
238
- np = of_find_compatible_node (NULL , NULL , "fsl,imx6q-ocotp" );
239
- if (!np )
240
- return - ENOENT ;
238
+ struct regmap * ocotp ;
241
239
242
- base = of_iomap (np , 0 );
243
- of_node_put (np );
244
- if (!base ) {
245
- dev_err (dev , "failed to map ocotp\n" );
246
- return - EFAULT ;
247
- }
240
+ ocotp = syscon_regmap_lookup_by_compatible ("fsl,imx6q-ocotp" );
241
+ if (IS_ERR (ocotp ))
242
+ return - ENOENT ;
248
243
249
244
/*
250
245
* SPEED_GRADING[1:0] defines the max speed of ARM:
@@ -254,8 +249,7 @@ static int imx6q_opp_check_speed_grading(struct device *dev)
254
249
* 2b'00: 792000000Hz;
255
250
* We need to set the max speed of ARM according to fuse map.
256
251
*/
257
- val = readl_relaxed (base + OCOTP_CFG3 );
258
- iounmap (base );
252
+ regmap_read (ocotp , OCOTP_CFG3 , & val );
259
253
}
260
254
261
255
val >>= OCOTP_CFG3_SPEED_SHIFT ;
@@ -290,25 +284,16 @@ static int imx6ul_opp_check_speed_grading(struct device *dev)
290
284
if (ret )
291
285
return ret ;
292
286
} else {
293
- struct device_node * np ;
294
- void __iomem * base ;
295
-
296
- np = of_find_compatible_node (NULL , NULL , "fsl,imx6ul-ocotp" );
297
- if (!np )
298
- np = of_find_compatible_node (NULL , NULL ,
299
- "fsl,imx6ull-ocotp" );
300
- if (!np )
301
- return - ENOENT ;
287
+ struct regmap * ocotp ;
302
288
303
- base = of_iomap ( np , 0 );
304
- of_node_put ( np );
305
- if (! base ) {
306
- dev_err ( dev , "failed to map ocotp\n" );
307
- return - EFAULT ;
308
- }
289
+ ocotp = syscon_regmap_lookup_by_compatible ( "fsl,imx6ul-ocotp" );
290
+ if ( IS_ERR ( ocotp ))
291
+ ocotp = syscon_regmap_lookup_by_compatible ( "fsl,imx6ull-ocotp" );
292
+
293
+ if ( IS_ERR ( ocotp ))
294
+ return - ENOENT ;
309
295
310
- val = readl_relaxed (base + OCOTP_CFG3 );
311
- iounmap (base );
296
+ regmap_read (ocotp , OCOTP_CFG3 , & val );
312
297
}
313
298
314
299
/*
0 commit comments