@@ -1101,23 +1101,24 @@ static const struct component_ops sun6i_dsi_ops = {
1101
1101
1102
1102
static int sun6i_dsi_probe (struct platform_device * pdev )
1103
1103
{
1104
+ const struct sun6i_dsi_variant * variant ;
1104
1105
struct device * dev = & pdev -> dev ;
1105
- const char * bus_clk_name = NULL ;
1106
1106
struct sun6i_dsi * dsi ;
1107
1107
void __iomem * base ;
1108
1108
int ret ;
1109
1109
1110
+ variant = device_get_match_data (dev );
1111
+ if (!variant )
1112
+ return - EINVAL ;
1113
+
1110
1114
dsi = devm_kzalloc (dev , sizeof (* dsi ), GFP_KERNEL );
1111
1115
if (!dsi )
1112
1116
return - ENOMEM ;
1113
1117
dev_set_drvdata (dev , dsi );
1114
1118
dsi -> dev = dev ;
1115
1119
dsi -> host .ops = & sun6i_dsi_host_ops ;
1116
1120
dsi -> host .dev = dev ;
1117
-
1118
- if (of_device_is_compatible (dev -> of_node ,
1119
- "allwinner,sun6i-a31-mipi-dsi" ))
1120
- bus_clk_name = "bus" ;
1121
+ dsi -> variant = variant ;
1121
1122
1122
1123
base = devm_platform_ioremap_resource (pdev , 0 );
1123
1124
if (IS_ERR (base )) {
@@ -1142,7 +1143,7 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
1142
1143
return PTR_ERR (dsi -> regs );
1143
1144
}
1144
1145
1145
- dsi -> bus_clk = devm_clk_get (dev , bus_clk_name );
1146
+ dsi -> bus_clk = devm_clk_get (dev , variant -> has_mod_clk ? "bus" : NULL );
1146
1147
if (IS_ERR (dsi -> bus_clk ))
1147
1148
return dev_err_probe (dev , PTR_ERR (dsi -> bus_clk ),
1148
1149
"Couldn't get the DSI bus clock\n" );
@@ -1151,21 +1152,21 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
1151
1152
if (ret )
1152
1153
return ret ;
1153
1154
1154
- if (of_device_is_compatible (dev -> of_node ,
1155
- "allwinner,sun6i-a31-mipi-dsi" )) {
1155
+ if (variant -> has_mod_clk ) {
1156
1156
dsi -> mod_clk = devm_clk_get (dev , "mod" );
1157
1157
if (IS_ERR (dsi -> mod_clk )) {
1158
1158
dev_err (dev , "Couldn't get the DSI mod clock\n" );
1159
1159
ret = PTR_ERR (dsi -> mod_clk );
1160
1160
goto err_attach_clk ;
1161
1161
}
1162
- }
1163
1162
1164
- /*
1165
- * In order to operate properly, that clock seems to be always
1166
- * set to 297MHz.
1167
- */
1168
- clk_set_rate_exclusive (dsi -> mod_clk , 297000000 );
1163
+ /*
1164
+ * In order to operate properly, the module clock on the
1165
+ * A31 variant always seems to be set to 297MHz.
1166
+ */
1167
+ if (variant -> set_mod_clk )
1168
+ clk_set_rate_exclusive (dsi -> mod_clk , 297000000 );
1169
+ }
1169
1170
1170
1171
dsi -> dphy = devm_phy_get (dev , "dphy" );
1171
1172
if (IS_ERR (dsi -> dphy )) {
@@ -1191,7 +1192,8 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
1191
1192
err_remove_dsi_host :
1192
1193
mipi_dsi_host_unregister (& dsi -> host );
1193
1194
err_unprotect_clk :
1194
- clk_rate_exclusive_put (dsi -> mod_clk );
1195
+ if (dsi -> variant -> has_mod_clk && dsi -> variant -> set_mod_clk )
1196
+ clk_rate_exclusive_put (dsi -> mod_clk );
1195
1197
err_attach_clk :
1196
1198
regmap_mmio_detach_clk (dsi -> regs );
1197
1199
@@ -1205,16 +1207,31 @@ static int sun6i_dsi_remove(struct platform_device *pdev)
1205
1207
1206
1208
component_del (& pdev -> dev , & sun6i_dsi_ops );
1207
1209
mipi_dsi_host_unregister (& dsi -> host );
1208
- clk_rate_exclusive_put (dsi -> mod_clk );
1210
+ if (dsi -> variant -> has_mod_clk && dsi -> variant -> set_mod_clk )
1211
+ clk_rate_exclusive_put (dsi -> mod_clk );
1209
1212
1210
1213
regmap_mmio_detach_clk (dsi -> regs );
1211
1214
1212
1215
return 0 ;
1213
1216
}
1214
1217
1218
+ static const struct sun6i_dsi_variant sun6i_a31_mipi_dsi_variant = {
1219
+ .has_mod_clk = true,
1220
+ .set_mod_clk = true,
1221
+ };
1222
+
1223
+ static const struct sun6i_dsi_variant sun50i_a64_mipi_dsi_variant = {
1224
+ };
1225
+
1215
1226
static const struct of_device_id sun6i_dsi_of_table [] = {
1216
- { .compatible = "allwinner,sun6i-a31-mipi-dsi" },
1217
- { .compatible = "allwinner,sun50i-a64-mipi-dsi" },
1227
+ {
1228
+ .compatible = "allwinner,sun6i-a31-mipi-dsi" ,
1229
+ .data = & sun6i_a31_mipi_dsi_variant ,
1230
+ },
1231
+ {
1232
+ .compatible = "allwinner,sun50i-a64-mipi-dsi" ,
1233
+ .data = & sun50i_a64_mipi_dsi_variant ,
1234
+ },
1218
1235
{ }
1219
1236
};
1220
1237
MODULE_DEVICE_TABLE (of , sun6i_dsi_of_table );
0 commit comments