@@ -153,25 +153,25 @@ int sun6i_csi_set_power(struct sun6i_csi_device *csi_dev, bool enable)
153
153
if (!enable ) {
154
154
regmap_update_bits (regmap , CSI_EN_REG , CSI_EN_CSI_EN , 0 );
155
155
156
- clk_disable_unprepare (csi_dev -> clk_ram );
156
+ clk_disable_unprepare (csi_dev -> clock_ram );
157
157
if (of_device_is_compatible (dev -> of_node ,
158
158
"allwinner,sun50i-a64-csi" ))
159
- clk_rate_exclusive_put (csi_dev -> clk_mod );
160
- clk_disable_unprepare (csi_dev -> clk_mod );
159
+ clk_rate_exclusive_put (csi_dev -> clock_mod );
160
+ clk_disable_unprepare (csi_dev -> clock_mod );
161
161
reset_control_assert (csi_dev -> reset );
162
162
return 0 ;
163
163
}
164
164
165
- ret = clk_prepare_enable (csi_dev -> clk_mod );
165
+ ret = clk_prepare_enable (csi_dev -> clock_mod );
166
166
if (ret ) {
167
167
dev_err (csi_dev -> dev , "Enable csi clk err %d\n" , ret );
168
168
return ret ;
169
169
}
170
170
171
171
if (of_device_is_compatible (dev -> of_node , "allwinner,sun50i-a64-csi" ))
172
- clk_set_rate_exclusive (csi_dev -> clk_mod , 300000000 );
172
+ clk_set_rate_exclusive (csi_dev -> clock_mod , 300000000 );
173
173
174
- ret = clk_prepare_enable (csi_dev -> clk_ram );
174
+ ret = clk_prepare_enable (csi_dev -> clock_ram );
175
175
if (ret ) {
176
176
dev_err (csi_dev -> dev , "Enable clk_dram_csi clk err %d\n" , ret );
177
177
goto clk_mod_disable ;
@@ -188,11 +188,11 @@ int sun6i_csi_set_power(struct sun6i_csi_device *csi_dev, bool enable)
188
188
return 0 ;
189
189
190
190
clk_ram_disable :
191
- clk_disable_unprepare (csi_dev -> clk_ram );
191
+ clk_disable_unprepare (csi_dev -> clock_ram );
192
192
clk_mod_disable :
193
193
if (of_device_is_compatible (dev -> of_node , "allwinner,sun50i-a64-csi" ))
194
- clk_rate_exclusive_put (csi_dev -> clk_mod );
195
- clk_disable_unprepare (csi_dev -> clk_mod );
194
+ clk_rate_exclusive_put (csi_dev -> clock_mod );
195
+ clk_disable_unprepare (csi_dev -> clock_mod );
196
196
return ret ;
197
197
}
198
198
@@ -773,12 +773,11 @@ static int sun6i_csi_v4l2_init(struct sun6i_csi_device *csi_dev)
773
773
return ret ;
774
774
}
775
775
776
- /* -----------------------------------------------------------------------------
777
- * Resources and IRQ
778
- */
779
- static irqreturn_t sun6i_csi_isr (int irq , void * dev_id )
776
+ /* Platform */
777
+
778
+ static irqreturn_t sun6i_csi_interrupt (int irq , void * private )
780
779
{
781
- struct sun6i_csi_device * csi_dev = ( struct sun6i_csi_device * ) dev_id ;
780
+ struct sun6i_csi_device * csi_dev = private ;
782
781
struct regmap * regmap = csi_dev -> regmap ;
783
782
u32 status ;
784
783
@@ -813,73 +812,82 @@ static const struct regmap_config sun6i_csi_regmap_config = {
813
812
.max_register = 0x9c ,
814
813
};
815
814
816
- static int sun6i_csi_resource_request (struct sun6i_csi_device * csi_dev ,
817
- struct platform_device * pdev )
815
+ static int sun6i_csi_resources_setup (struct sun6i_csi_device * csi_dev ,
816
+ struct platform_device * platform_dev )
818
817
{
818
+ struct device * dev = csi_dev -> dev ;
819
819
void __iomem * io_base ;
820
820
int ret ;
821
821
int irq ;
822
822
823
- io_base = devm_platform_ioremap_resource (pdev , 0 );
823
+ /* Registers */
824
+
825
+ io_base = devm_platform_ioremap_resource (platform_dev , 0 );
824
826
if (IS_ERR (io_base ))
825
827
return PTR_ERR (io_base );
826
828
827
- csi_dev -> regmap = devm_regmap_init_mmio_clk (& pdev -> dev , "bus" , io_base ,
829
+ csi_dev -> regmap = devm_regmap_init_mmio_clk (dev , "bus" , io_base ,
828
830
& sun6i_csi_regmap_config );
829
831
if (IS_ERR (csi_dev -> regmap )) {
830
- dev_err (& pdev -> dev , "Failed to init register map\n" );
832
+ dev_err (dev , "failed to init register map\n" );
831
833
return PTR_ERR (csi_dev -> regmap );
832
834
}
833
835
834
- csi_dev -> clk_mod = devm_clk_get (& pdev -> dev , "mod" );
835
- if (IS_ERR (csi_dev -> clk_mod )) {
836
- dev_err (& pdev -> dev , "Unable to acquire csi clock\n" );
837
- return PTR_ERR (csi_dev -> clk_mod );
836
+ /* Clocks */
837
+
838
+ csi_dev -> clock_mod = devm_clk_get (dev , "mod" );
839
+ if (IS_ERR (csi_dev -> clock_mod )) {
840
+ dev_err (dev , "failed to acquire module clock\n" );
841
+ return PTR_ERR (csi_dev -> clock_mod );
838
842
}
839
843
840
- csi_dev -> clk_ram = devm_clk_get (& pdev -> dev , "ram" );
841
- if (IS_ERR (csi_dev -> clk_ram )) {
842
- dev_err (& pdev -> dev , "Unable to acquire dram-csi clock\n" );
843
- return PTR_ERR (csi_dev -> clk_ram );
844
+ csi_dev -> clock_ram = devm_clk_get (dev , "ram" );
845
+ if (IS_ERR (csi_dev -> clock_ram )) {
846
+ dev_err (dev , "failed to acquire ram clock\n" );
847
+ return PTR_ERR (csi_dev -> clock_ram );
844
848
}
845
849
846
- csi_dev -> reset = devm_reset_control_get_shared (& pdev -> dev , NULL );
850
+ /* Reset */
851
+
852
+ csi_dev -> reset = devm_reset_control_get_shared (dev , NULL );
847
853
if (IS_ERR (csi_dev -> reset )) {
848
- dev_err (& pdev -> dev , "Cannot get reset controller \n" );
854
+ dev_err (dev , "failed to acquire reset \n" );
849
855
return PTR_ERR (csi_dev -> reset );
850
856
}
851
857
852
- irq = platform_get_irq (pdev , 0 );
858
+ /* Interrupt */
859
+
860
+ irq = platform_get_irq (platform_dev , 0 );
853
861
if (irq < 0 )
854
862
return - ENXIO ;
855
863
856
- ret = devm_request_irq (& pdev -> dev , irq , sun6i_csi_isr , 0 ,
857
- SUN6I_CSI_NAME , csi_dev );
864
+ ret = devm_request_irq (dev , irq , sun6i_csi_interrupt , 0 , SUN6I_CSI_NAME ,
865
+ csi_dev );
858
866
if (ret ) {
859
- dev_err (& pdev -> dev , "Cannot request csi IRQ \n" );
867
+ dev_err (dev , "failed to request interrupt \n" );
860
868
return ret ;
861
869
}
862
870
863
871
return 0 ;
864
872
}
865
873
866
- static int sun6i_csi_probe (struct platform_device * pdev )
874
+ static int sun6i_csi_probe (struct platform_device * platform_dev )
867
875
{
868
876
struct sun6i_csi_device * csi_dev ;
877
+ struct device * dev = & platform_dev -> dev ;
869
878
int ret ;
870
879
871
- csi_dev = devm_kzalloc (& pdev -> dev , sizeof (* csi_dev ), GFP_KERNEL );
880
+ csi_dev = devm_kzalloc (dev , sizeof (* csi_dev ), GFP_KERNEL );
872
881
if (!csi_dev )
873
882
return - ENOMEM ;
874
883
875
- csi_dev -> dev = & pdev -> dev ;
884
+ csi_dev -> dev = & platform_dev -> dev ;
885
+ platform_set_drvdata (platform_dev , csi_dev );
876
886
877
- ret = sun6i_csi_resource_request (csi_dev , pdev );
887
+ ret = sun6i_csi_resources_setup (csi_dev , platform_dev );
878
888
if (ret )
879
889
return ret ;
880
890
881
- platform_set_drvdata (pdev , csi_dev );
882
-
883
891
return sun6i_csi_v4l2_init (csi_dev );
884
892
}
885
893
@@ -900,16 +908,18 @@ static const struct of_device_id sun6i_csi_of_match[] = {
900
908
{ .compatible = "allwinner,sun50i-a64-csi" , },
901
909
{},
902
910
};
911
+
903
912
MODULE_DEVICE_TABLE (of , sun6i_csi_of_match );
904
913
905
914
static struct platform_driver sun6i_csi_platform_driver = {
906
- .probe = sun6i_csi_probe ,
907
- .remove = sun6i_csi_remove ,
908
- .driver = {
909
- .name = SUN6I_CSI_NAME ,
910
- .of_match_table = of_match_ptr (sun6i_csi_of_match ),
915
+ .probe = sun6i_csi_probe ,
916
+ .remove = sun6i_csi_remove ,
917
+ .driver = {
918
+ .name = SUN6I_CSI_NAME ,
919
+ .of_match_table = of_match_ptr (sun6i_csi_of_match ),
911
920
},
912
921
};
922
+
913
923
module_platform_driver (sun6i_csi_platform_driver );
914
924
915
925
MODULE_DESCRIPTION ("Allwinner A31 Camera Sensor Interface driver" );
0 commit comments