@@ -36,6 +36,11 @@ struct mpfs_sys_controller {
3636 struct kref consumers ;
3737};
3838
39+ struct mpfs_syscon_config {
40+ unsigned int nb_subdevs ;
41+ struct platform_device * subdevs ;
42+ };
43+
3944int mpfs_blocking_transaction (struct mpfs_sys_controller * sys_controller , struct mpfs_mss_msg * msg )
4045{
4146 unsigned long timeout = msecs_to_jiffies (MPFS_SYS_CTRL_TIMEOUT_MS );
@@ -110,25 +115,11 @@ struct mtd_info *mpfs_sys_controller_get_flash(struct mpfs_sys_controller *mpfs_
110115}
111116EXPORT_SYMBOL (mpfs_sys_controller_get_flash );
112117
113- static struct platform_device subdevs [] = {
114- {
115- .name = "mpfs-rng" ,
116- .id = -1 ,
117- },
118- {
119- .name = "mpfs-generic-service" ,
120- .id = -1 ,
121- },
122- {
123- .name = "mpfs-auto-update" ,
124- .id = -1 ,
125- },
126- };
127-
128118static int mpfs_sys_controller_probe (struct platform_device * pdev )
129119{
130120 struct device * dev = & pdev -> dev ;
131121 struct mpfs_sys_controller * sys_controller ;
122+ struct mpfs_syscon_config * of_data ;
132123 struct device_node * np ;
133124 int i , ret ;
134125
@@ -164,11 +155,17 @@ static int mpfs_sys_controller_probe(struct platform_device *pdev)
164155
165156 platform_set_drvdata (pdev , sys_controller );
166157
158+ of_data = (struct mpfs_syscon_config * ) device_get_match_data (dev );
159+ if (!of_data ) {
160+ dev_err (dev , "Error getting match data\n" );
161+ return - EINVAL ;
162+ }
167163
168- for (i = 0 ; i < ARRAY_SIZE (subdevs ); i ++ ) {
169- subdevs [i ].dev .parent = dev ;
170- if (platform_device_register (& subdevs [i ]))
171- dev_warn (dev , "Error registering sub device %s\n" , subdevs [i ].name );
164+ for (i = 0 ; i < of_data -> nb_subdevs ; i ++ ) {
165+ of_data -> subdevs [i ].dev .parent = dev ;
166+ if (platform_device_register (& of_data -> subdevs [i ]))
167+ dev_warn (dev , "Error registering sub device %s\n" ,
168+ of_data -> subdevs [i ].name );
172169 }
173170
174171 dev_info (& pdev -> dev , "Registered MPFS system controller\n" );
@@ -183,8 +180,45 @@ static void mpfs_sys_controller_remove(struct platform_device *pdev)
183180 mpfs_sys_controller_put (sys_controller );
184181}
185182
183+ static struct platform_device mpfs_subdevs [] = {
184+ {
185+ .name = "mpfs-rng" ,
186+ .id = -1 ,
187+ },
188+ {
189+ .name = "mpfs-generic-service" ,
190+ .id = -1 ,
191+ },
192+ {
193+ .name = "mpfs-auto-update" ,
194+ .id = -1 ,
195+ },
196+ };
197+
198+ static struct platform_device pic64gx_subdevs [] = {
199+ {
200+ .name = "mpfs-rng" ,
201+ .id = -1 ,
202+ },
203+ {
204+ .name = "mpfs-generic-service" ,
205+ .id = -1 ,
206+ },
207+ };
208+
209+ static const struct mpfs_syscon_config mpfs_config = {
210+ .nb_subdevs = ARRAY_SIZE (mpfs_subdevs ),
211+ .subdevs = mpfs_subdevs ,
212+ };
213+
214+ static const struct mpfs_syscon_config pic64gx_config = {
215+ .nb_subdevs = ARRAY_SIZE (pic64gx_subdevs ),
216+ .subdevs = pic64gx_subdevs ,
217+ };
218+
186219static const struct of_device_id mpfs_sys_controller_of_match [] = {
187- {.compatible = "microchip,mpfs-sys-controller" , },
220+ {.compatible = "microchip,mpfs-sys-controller" , .data = & mpfs_config },
221+ {.compatible = "microchip,pic64gx-sys-controller" , .data = & pic64gx_config },
188222 {},
189223};
190224MODULE_DEVICE_TABLE (of , mpfs_sys_controller_of_match );
0 commit comments