1414#include <linux/pm_opp.h>
1515#include <linux/platform_device.h>
1616#include <linux/regulator/consumer.h>
17+ #include <linux/mfd/syscon.h>
18+ #include <linux/regmap.h>
1719
1820#define PU_SOC_VOLTAGE_NORMAL 1250000
1921#define PU_SOC_VOLTAGE_HIGH 1275000
@@ -225,8 +227,6 @@ static void imx6x_disable_freq_in_opp(struct device *dev, unsigned long freq)
225227
226228static int imx6q_opp_check_speed_grading (struct device * dev )
227229{
228- struct device_node * np ;
229- void __iomem * base ;
230230 u32 val ;
231231 int ret ;
232232
@@ -235,16 +235,11 @@ static int imx6q_opp_check_speed_grading(struct device *dev)
235235 if (ret )
236236 return ret ;
237237 } else {
238- np = of_find_compatible_node (NULL , NULL , "fsl,imx6q-ocotp" );
239- if (!np )
240- return - ENOENT ;
238+ struct regmap * ocotp ;
241239
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 ;
248243
249244 /*
250245 * SPEED_GRADING[1:0] defines the max speed of ARM:
@@ -254,8 +249,7 @@ static int imx6q_opp_check_speed_grading(struct device *dev)
254249 * 2b'00: 792000000Hz;
255250 * We need to set the max speed of ARM according to fuse map.
256251 */
257- val = readl_relaxed (base + OCOTP_CFG3 );
258- iounmap (base );
252+ regmap_read (ocotp , OCOTP_CFG3 , & val );
259253 }
260254
261255 val >>= OCOTP_CFG3_SPEED_SHIFT ;
@@ -290,25 +284,16 @@ static int imx6ul_opp_check_speed_grading(struct device *dev)
290284 if (ret )
291285 return ret ;
292286 } 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 ;
302288
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 ;
309295
310- val = readl_relaxed (base + OCOTP_CFG3 );
311- iounmap (base );
296+ regmap_read (ocotp , OCOTP_CFG3 , & val );
312297 }
313298
314299 /*
0 commit comments