diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-06-04 06:02:52 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-06-17 06:44:41 -0400 |
commit | 7e328f5adcabb0b08e713f202b4a0fc388b2319e (patch) | |
tree | d6eb4df6c973c45e7eb83c0668bbc9ca4026bf9e /drivers/video | |
parent | f99467b3549be1c87757e564d18eea6e541060c4 (diff) |
OMAPDSS: refactor dss probe function
Refactor dss probe function by extracting the setup for video plls into
a separate function. The call to this function is also moved to a
slightly earlier phase, so that in error case we can bail out more
easily.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/fbdev/omap2/dss/dss.c | 125 |
1 files changed, 69 insertions, 56 deletions
diff --git a/drivers/video/fbdev/omap2/dss/dss.c b/drivers/video/fbdev/omap2/dss/dss.c index 35601ab232e3..1ce47441efe3 100644 --- a/drivers/video/fbdev/omap2/dss/dss.c +++ b/drivers/video/fbdev/omap2/dss/dss.c | |||
@@ -1026,14 +1026,73 @@ static void __exit dss_uninit_ports(struct platform_device *pdev) | |||
1026 | } while ((port = omapdss_of_get_next_port(parent, port)) != NULL); | 1026 | } while ((port = omapdss_of_get_next_port(parent, port)) != NULL); |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | static int dss_video_pll_probe(struct platform_device *pdev) | ||
1030 | { | ||
1031 | struct device_node *np = pdev->dev.of_node; | ||
1032 | struct regulator *pll_regulator; | ||
1033 | int r; | ||
1034 | |||
1035 | if (!np) | ||
1036 | return 0; | ||
1037 | |||
1038 | if (of_property_read_bool(np, "syscon-pll-ctrl")) { | ||
1039 | dss.syscon_pll_ctrl = syscon_regmap_lookup_by_phandle(np, | ||
1040 | "syscon-pll-ctrl"); | ||
1041 | if (IS_ERR(dss.syscon_pll_ctrl)) { | ||
1042 | dev_err(&pdev->dev, | ||
1043 | "failed to get syscon-pll-ctrl regmap\n"); | ||
1044 | return PTR_ERR(dss.syscon_pll_ctrl); | ||
1045 | } | ||
1046 | |||
1047 | if (of_property_read_u32_index(np, "syscon-pll-ctrl", 1, | ||
1048 | &dss.syscon_pll_ctrl_offset)) { | ||
1049 | dev_err(&pdev->dev, | ||
1050 | "failed to get syscon-pll-ctrl offset\n"); | ||
1051 | return -EINVAL; | ||
1052 | } | ||
1053 | } | ||
1054 | |||
1055 | pll_regulator = devm_regulator_get(&pdev->dev, "vdda_video"); | ||
1056 | if (IS_ERR(pll_regulator)) { | ||
1057 | r = PTR_ERR(pll_regulator); | ||
1058 | |||
1059 | switch (r) { | ||
1060 | case -ENOENT: | ||
1061 | pll_regulator = NULL; | ||
1062 | break; | ||
1063 | |||
1064 | case -EPROBE_DEFER: | ||
1065 | return -EPROBE_DEFER; | ||
1066 | |||
1067 | default: | ||
1068 | DSSERR("can't get DPLL VDDA regulator\n"); | ||
1069 | return r; | ||
1070 | } | ||
1071 | } | ||
1072 | |||
1073 | if (of_property_match_string(np, "reg-names", "pll1") >= 0) { | ||
1074 | dss.video1_pll = dss_video_pll_init(pdev, 0, pll_regulator); | ||
1075 | if (IS_ERR(dss.video1_pll)) | ||
1076 | return PTR_ERR(dss.video1_pll); | ||
1077 | } | ||
1078 | |||
1079 | if (of_property_match_string(np, "reg-names", "pll2") >= 0) { | ||
1080 | dss.video2_pll = dss_video_pll_init(pdev, 1, pll_regulator); | ||
1081 | if (IS_ERR(dss.video2_pll)) { | ||
1082 | dss_video_pll_uninit(dss.video1_pll); | ||
1083 | return PTR_ERR(dss.video2_pll); | ||
1084 | } | ||
1085 | } | ||
1086 | |||
1087 | return 0; | ||
1088 | } | ||
1089 | |||
1029 | /* DSS HW IP initialisation */ | 1090 | /* DSS HW IP initialisation */ |
1030 | static int __init omap_dsshw_probe(struct platform_device *pdev) | 1091 | static int __init omap_dsshw_probe(struct platform_device *pdev) |
1031 | { | 1092 | { |
1032 | struct resource *dss_mem; | 1093 | struct resource *dss_mem; |
1033 | struct device_node *np = pdev->dev.of_node; | ||
1034 | u32 rev; | 1094 | u32 rev; |
1035 | int r; | 1095 | int r; |
1036 | struct regulator *pll_regulator; | ||
1037 | 1096 | ||
1038 | dss.pdev = pdev; | 1097 | dss.pdev = pdev; |
1039 | 1098 | ||
@@ -1062,6 +1121,10 @@ static int __init omap_dsshw_probe(struct platform_device *pdev) | |||
1062 | if (r) | 1121 | if (r) |
1063 | goto err_setup_clocks; | 1122 | goto err_setup_clocks; |
1064 | 1123 | ||
1124 | r = dss_video_pll_probe(pdev); | ||
1125 | if (r) | ||
1126 | goto err_pll_init; | ||
1127 | |||
1065 | pm_runtime_enable(&pdev->dev); | 1128 | pm_runtime_enable(&pdev->dev); |
1066 | 1129 | ||
1067 | r = dss_runtime_get(); | 1130 | r = dss_runtime_get(); |
@@ -1088,57 +1151,6 @@ static int __init omap_dsshw_probe(struct platform_device *pdev) | |||
1088 | 1151 | ||
1089 | dss_init_ports(pdev); | 1152 | dss_init_ports(pdev); |
1090 | 1153 | ||
1091 | if (np && of_property_read_bool(np, "syscon-pll-ctrl")) { | ||
1092 | dss.syscon_pll_ctrl = syscon_regmap_lookup_by_phandle(np, | ||
1093 | "syscon-pll-ctrl"); | ||
1094 | if (IS_ERR(dss.syscon_pll_ctrl)) { | ||
1095 | dev_err(&pdev->dev, | ||
1096 | "failed to get syscon-pll-ctrl regmap\n"); | ||
1097 | return PTR_ERR(dss.syscon_pll_ctrl); | ||
1098 | } | ||
1099 | |||
1100 | if (of_property_read_u32_index(np, "syscon-pll-ctrl", 1, | ||
1101 | &dss.syscon_pll_ctrl_offset)) { | ||
1102 | dev_err(&pdev->dev, | ||
1103 | "failed to get syscon-pll-ctrl offset\n"); | ||
1104 | return -EINVAL; | ||
1105 | } | ||
1106 | } | ||
1107 | |||
1108 | pll_regulator = devm_regulator_get(&pdev->dev, "vdda_video"); | ||
1109 | if (IS_ERR(pll_regulator)) { | ||
1110 | r = PTR_ERR(pll_regulator); | ||
1111 | |||
1112 | switch (r) { | ||
1113 | case -ENOENT: | ||
1114 | pll_regulator = NULL; | ||
1115 | break; | ||
1116 | |||
1117 | case -EPROBE_DEFER: | ||
1118 | return -EPROBE_DEFER; | ||
1119 | |||
1120 | default: | ||
1121 | DSSERR("can't get DPLL VDDA regulator\n"); | ||
1122 | return r; | ||
1123 | } | ||
1124 | } | ||
1125 | |||
1126 | if (of_property_match_string(np, "reg-names", "pll1") >= 0) { | ||
1127 | dss.video1_pll = dss_video_pll_init(pdev, 0, pll_regulator); | ||
1128 | if (IS_ERR(dss.video1_pll)) { | ||
1129 | r = PTR_ERR(dss.video1_pll); | ||
1130 | goto err_pll_init; | ||
1131 | } | ||
1132 | } | ||
1133 | |||
1134 | if (of_property_match_string(np, "reg-names", "pll2") >= 0) { | ||
1135 | dss.video2_pll = dss_video_pll_init(pdev, 1, pll_regulator); | ||
1136 | if (IS_ERR(dss.video2_pll)) { | ||
1137 | r = PTR_ERR(dss.video2_pll); | ||
1138 | goto err_pll_init; | ||
1139 | } | ||
1140 | } | ||
1141 | |||
1142 | rev = dss_read_reg(DSS_REVISION); | 1154 | rev = dss_read_reg(DSS_REVISION); |
1143 | printk(KERN_INFO "OMAP DSS rev %d.%d\n", | 1155 | printk(KERN_INFO "OMAP DSS rev %d.%d\n", |
1144 | FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0)); | 1156 | FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0)); |
@@ -1153,14 +1165,15 @@ static int __init omap_dsshw_probe(struct platform_device *pdev) | |||
1153 | 1165 | ||
1154 | return 0; | 1166 | return 0; |
1155 | 1167 | ||
1156 | err_pll_init: | 1168 | err_runtime_get: |
1169 | pm_runtime_disable(&pdev->dev); | ||
1170 | |||
1157 | if (dss.video1_pll) | 1171 | if (dss.video1_pll) |
1158 | dss_video_pll_uninit(dss.video1_pll); | 1172 | dss_video_pll_uninit(dss.video1_pll); |
1159 | 1173 | ||
1160 | if (dss.video2_pll) | 1174 | if (dss.video2_pll) |
1161 | dss_video_pll_uninit(dss.video2_pll); | 1175 | dss_video_pll_uninit(dss.video2_pll); |
1162 | err_runtime_get: | 1176 | err_pll_init: |
1163 | pm_runtime_disable(&pdev->dev); | ||
1164 | err_setup_clocks: | 1177 | err_setup_clocks: |
1165 | dss_put_clocks(); | 1178 | dss_put_clocks(); |
1166 | return r; | 1179 | return r; |