@@ -76,8 +76,6 @@ static void msm_hdmi_destroy(struct hdmi *hdmi)
7676
7777 if (hdmi -> i2c )
7878 msm_hdmi_i2c_destroy (hdmi -> i2c );
79-
80- platform_set_drvdata (hdmi -> pdev , NULL );
8179}
8280
8381static int msm_hdmi_get_phy (struct hdmi * hdmi )
@@ -117,142 +115,10 @@ static int msm_hdmi_get_phy(struct hdmi *hdmi)
117115 * we are to EPROBE_DEFER we want to do it here, rather than later
118116 * at modeset_init() time
119117 */
120- static struct hdmi * msm_hdmi_init (struct platform_device * pdev )
118+ static int msm_hdmi_init (struct hdmi * hdmi )
121119{
122- struct hdmi_platform_config * config = pdev -> dev .platform_data ;
123- struct hdmi * hdmi = NULL ;
124- struct resource * res ;
125- int i , ret ;
126-
127- hdmi = devm_kzalloc (& pdev -> dev , sizeof (* hdmi ), GFP_KERNEL );
128- if (!hdmi ) {
129- ret = - ENOMEM ;
130- goto fail ;
131- }
132-
133- hdmi -> pdev = pdev ;
134- hdmi -> config = config ;
135- spin_lock_init (& hdmi -> reg_lock );
136-
137- ret = drm_of_find_panel_or_bridge (pdev -> dev .of_node , 1 , 0 , NULL , & hdmi -> next_bridge );
138- if (ret && ret != - ENODEV )
139- goto fail ;
140-
141- hdmi -> mmio = msm_ioremap (pdev , "core_physical" );
142- if (IS_ERR (hdmi -> mmio )) {
143- ret = PTR_ERR (hdmi -> mmio );
144- goto fail ;
145- }
146-
147- /* HDCP needs physical address of hdmi register */
148- res = platform_get_resource_byname (pdev , IORESOURCE_MEM ,
149- "core_physical" );
150- if (!res ) {
151- ret = - EINVAL ;
152- goto fail ;
153- }
154- hdmi -> mmio_phy_addr = res -> start ;
155-
156- hdmi -> qfprom_mmio = msm_ioremap (pdev , "qfprom_physical" );
157- if (IS_ERR (hdmi -> qfprom_mmio )) {
158- DRM_DEV_INFO (& pdev -> dev , "can't find qfprom resource\n" );
159- hdmi -> qfprom_mmio = NULL ;
160- }
161-
162- hdmi -> hpd_regs = devm_kcalloc (& pdev -> dev ,
163- config -> hpd_reg_cnt ,
164- sizeof (hdmi -> hpd_regs [0 ]),
165- GFP_KERNEL );
166- if (!hdmi -> hpd_regs ) {
167- ret = - ENOMEM ;
168- goto fail ;
169- }
170- for (i = 0 ; i < config -> hpd_reg_cnt ; i ++ )
171- hdmi -> hpd_regs [i ].supply = config -> hpd_reg_names [i ];
172-
173- ret = devm_regulator_bulk_get (& pdev -> dev , config -> hpd_reg_cnt , hdmi -> hpd_regs );
174- if (ret ) {
175- DRM_DEV_ERROR (& pdev -> dev , "failed to get hpd regulator: %d\n" , ret );
176- goto fail ;
177- }
178-
179- hdmi -> pwr_regs = devm_kcalloc (& pdev -> dev ,
180- config -> pwr_reg_cnt ,
181- sizeof (hdmi -> pwr_regs [0 ]),
182- GFP_KERNEL );
183- if (!hdmi -> pwr_regs ) {
184- ret = - ENOMEM ;
185- goto fail ;
186- }
187-
188- for (i = 0 ; i < config -> pwr_reg_cnt ; i ++ )
189- hdmi -> pwr_regs [i ].supply = config -> pwr_reg_names [i ];
190-
191- ret = devm_regulator_bulk_get (& pdev -> dev , config -> pwr_reg_cnt , hdmi -> pwr_regs );
192- if (ret ) {
193- DRM_DEV_ERROR (& pdev -> dev , "failed to get pwr regulator: %d\n" , ret );
194- goto fail ;
195- }
196-
197- hdmi -> hpd_clks = devm_kcalloc (& pdev -> dev ,
198- config -> hpd_clk_cnt ,
199- sizeof (hdmi -> hpd_clks [0 ]),
200- GFP_KERNEL );
201- if (!hdmi -> hpd_clks ) {
202- ret = - ENOMEM ;
203- goto fail ;
204- }
205- for (i = 0 ; i < config -> hpd_clk_cnt ; i ++ ) {
206- struct clk * clk ;
207-
208- clk = msm_clk_get (pdev , config -> hpd_clk_names [i ]);
209- if (IS_ERR (clk )) {
210- ret = PTR_ERR (clk );
211- DRM_DEV_ERROR (& pdev -> dev , "failed to get hpd clk: %s (%d)\n" ,
212- config -> hpd_clk_names [i ], ret );
213- goto fail ;
214- }
215-
216- hdmi -> hpd_clks [i ] = clk ;
217- }
218-
219- hdmi -> pwr_clks = devm_kcalloc (& pdev -> dev ,
220- config -> pwr_clk_cnt ,
221- sizeof (hdmi -> pwr_clks [0 ]),
222- GFP_KERNEL );
223- if (!hdmi -> pwr_clks ) {
224- ret = - ENOMEM ;
225- goto fail ;
226- }
227- for (i = 0 ; i < config -> pwr_clk_cnt ; i ++ ) {
228- struct clk * clk ;
229-
230- clk = msm_clk_get (pdev , config -> pwr_clk_names [i ]);
231- if (IS_ERR (clk )) {
232- ret = PTR_ERR (clk );
233- DRM_DEV_ERROR (& pdev -> dev , "failed to get pwr clk: %s (%d)\n" ,
234- config -> pwr_clk_names [i ], ret );
235- goto fail ;
236- }
237-
238- hdmi -> pwr_clks [i ] = clk ;
239- }
240-
241- hdmi -> hpd_gpiod = devm_gpiod_get_optional (& pdev -> dev , "hpd" , GPIOD_IN );
242- /* This will catch e.g. -EPROBE_DEFER */
243- if (IS_ERR (hdmi -> hpd_gpiod )) {
244- ret = PTR_ERR (hdmi -> hpd_gpiod );
245- DRM_DEV_ERROR (& pdev -> dev , "failed to get hpd gpio: (%d)\n" , ret );
246- goto fail ;
247- }
248-
249- if (!hdmi -> hpd_gpiod )
250- DBG ("failed to get HPD gpio" );
251-
252- if (hdmi -> hpd_gpiod )
253- gpiod_set_consumer_name (hdmi -> hpd_gpiod , "HDMI_HPD" );
254-
255- devm_pm_runtime_enable (& pdev -> dev );
120+ struct platform_device * pdev = hdmi -> pdev ;
121+ int ret ;
256122
257123 hdmi -> workq = alloc_ordered_workqueue ("msm_hdmi" , 0 );
258124
@@ -276,13 +142,13 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
276142 hdmi -> hdcp_ctrl = NULL ;
277143 }
278144
279- return hdmi ;
145+ return 0 ;
280146
281147fail :
282148 if (hdmi )
283149 msm_hdmi_destroy (hdmi );
284150
285- return ERR_PTR ( ret ) ;
151+ return ret ;
286152}
287153
288154/* Second part of initialization, the drm/kms level modeset_init,
@@ -297,7 +163,6 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi,
297163 struct drm_device * dev , struct drm_encoder * encoder )
298164{
299165 struct msm_drm_private * priv = dev -> dev_private ;
300- struct platform_device * pdev = hdmi -> pdev ;
301166 int ret ;
302167
303168 if (priv -> num_bridges == ARRAY_SIZE (priv -> bridges )) {
@@ -337,13 +202,6 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi,
337202
338203 drm_connector_attach_encoder (hdmi -> connector , hdmi -> encoder );
339204
340- hdmi -> irq = irq_of_parse_and_map (pdev -> dev .of_node , 0 );
341- if (!hdmi -> irq ) {
342- ret = - EINVAL ;
343- DRM_DEV_ERROR (dev -> dev , "failed to get irq\n" );
344- goto fail ;
345- }
346-
347205 ret = devm_request_irq (dev -> dev , hdmi -> irq ,
348206 msm_hdmi_irq , IRQF_TRIGGER_HIGH ,
349207 "hdmi_isr" , hdmi );
@@ -363,8 +221,6 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi,
363221
364222 priv -> bridges [priv -> num_bridges ++ ] = hdmi -> bridge ;
365223
366- platform_set_drvdata (pdev , hdmi );
367-
368224 return 0 ;
369225
370226fail :
@@ -392,7 +248,7 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi,
392248static const char * hpd_reg_names_8960 [] = {"core-vdda" };
393249static const char * hpd_clk_names_8960 [] = {"core" , "master_iface" , "slave_iface" };
394250
395- static struct hdmi_platform_config hdmi_tx_8960_config = {
251+ static const struct hdmi_platform_config hdmi_tx_8960_config = {
396252 HDMI_CFG (hpd_reg , 8960 ),
397253 HDMI_CFG (hpd_clk , 8960 ),
398254};
@@ -402,7 +258,7 @@ static const char *pwr_clk_names_8x74[] = {"extp", "alt_iface"};
402258static const char * hpd_clk_names_8x74 [] = {"iface" , "core" , "mdp_core" };
403259static unsigned long hpd_clk_freq_8x74 [] = {0 , 19200000 , 0 };
404260
405- static struct hdmi_platform_config hdmi_tx_8974_config = {
261+ static const struct hdmi_platform_config hdmi_tx_8974_config = {
406262 HDMI_CFG (pwr_reg , 8 x74 ),
407263 HDMI_CFG (pwr_clk , 8 x74 ),
408264 HDMI_CFG (hpd_clk , 8 x74 ),
@@ -517,23 +373,12 @@ static int msm_hdmi_register_audio_driver(struct hdmi *hdmi, struct device *dev)
517373static int msm_hdmi_bind (struct device * dev , struct device * master , void * data )
518374{
519375 struct msm_drm_private * priv = dev_get_drvdata (master );
520- struct hdmi_platform_config * hdmi_cfg ;
521- struct hdmi * hdmi ;
522- struct device_node * of_node = dev -> of_node ;
376+ struct hdmi * hdmi = dev_get_drvdata (dev );
523377 int err ;
524378
525- hdmi_cfg = (struct hdmi_platform_config * )
526- of_device_get_match_data (dev );
527- if (!hdmi_cfg ) {
528- DRM_DEV_ERROR (dev , "unknown hdmi_cfg: %pOFn\n" , of_node );
529- return - ENXIO ;
530- }
531-
532- dev -> platform_data = hdmi_cfg ;
533-
534- hdmi = msm_hdmi_init (to_platform_device (dev ));
535- if (IS_ERR (hdmi ))
536- return PTR_ERR (hdmi );
379+ err = msm_hdmi_init (hdmi );
380+ if (err )
381+ return err ;
537382 priv -> hdmi = hdmi ;
538383
539384 err = msm_hdmi_register_audio_driver (hdmi , dev );
@@ -566,6 +411,133 @@ static const struct component_ops msm_hdmi_ops = {
566411
567412static int msm_hdmi_dev_probe (struct platform_device * pdev )
568413{
414+ const struct hdmi_platform_config * config ;
415+ struct device * dev = & pdev -> dev ;
416+ struct hdmi * hdmi ;
417+ struct resource * res ;
418+ int i , ret ;
419+
420+ config = of_device_get_match_data (dev );
421+ if (!config )
422+ return - EINVAL ;
423+
424+ hdmi = devm_kzalloc (& pdev -> dev , sizeof (* hdmi ), GFP_KERNEL );
425+ if (!hdmi )
426+ return - ENOMEM ;
427+
428+ hdmi -> pdev = pdev ;
429+ hdmi -> config = config ;
430+ spin_lock_init (& hdmi -> reg_lock );
431+
432+ ret = drm_of_find_panel_or_bridge (pdev -> dev .of_node , 1 , 0 , NULL , & hdmi -> next_bridge );
433+ if (ret && ret != - ENODEV )
434+ return ret ;
435+
436+ hdmi -> mmio = msm_ioremap (pdev , "core_physical" );
437+ if (IS_ERR (hdmi -> mmio ))
438+ return PTR_ERR (hdmi -> mmio );
439+
440+ /* HDCP needs physical address of hdmi register */
441+ res = platform_get_resource_byname (pdev , IORESOURCE_MEM ,
442+ "core_physical" );
443+ if (!res )
444+ return - EINVAL ;
445+ hdmi -> mmio_phy_addr = res -> start ;
446+
447+ hdmi -> qfprom_mmio = msm_ioremap (pdev , "qfprom_physical" );
448+ if (IS_ERR (hdmi -> qfprom_mmio )) {
449+ DRM_DEV_INFO (& pdev -> dev , "can't find qfprom resource\n" );
450+ hdmi -> qfprom_mmio = NULL ;
451+ }
452+
453+ hdmi -> irq = platform_get_irq (pdev , 0 );
454+ if (hdmi -> irq < 0 )
455+ return hdmi -> irq ;
456+
457+ hdmi -> hpd_regs = devm_kcalloc (& pdev -> dev ,
458+ config -> hpd_reg_cnt ,
459+ sizeof (hdmi -> hpd_regs [0 ]),
460+ GFP_KERNEL );
461+ if (!hdmi -> hpd_regs )
462+ return - ENOMEM ;
463+
464+ for (i = 0 ; i < config -> hpd_reg_cnt ; i ++ )
465+ hdmi -> hpd_regs [i ].supply = config -> hpd_reg_names [i ];
466+
467+ ret = devm_regulator_bulk_get (& pdev -> dev , config -> hpd_reg_cnt , hdmi -> hpd_regs );
468+ if (ret )
469+ return dev_err_probe (dev , ret , "failed to get hpd regulators\n" );
470+
471+ hdmi -> pwr_regs = devm_kcalloc (& pdev -> dev ,
472+ config -> pwr_reg_cnt ,
473+ sizeof (hdmi -> pwr_regs [0 ]),
474+ GFP_KERNEL );
475+ if (!hdmi -> pwr_regs )
476+ return - ENOMEM ;
477+
478+ for (i = 0 ; i < config -> pwr_reg_cnt ; i ++ )
479+ hdmi -> pwr_regs [i ].supply = config -> pwr_reg_names [i ];
480+
481+ ret = devm_regulator_bulk_get (& pdev -> dev , config -> pwr_reg_cnt , hdmi -> pwr_regs );
482+ if (ret )
483+ return dev_err_probe (dev , ret , "failed to get pwr regulators\n" );
484+
485+ hdmi -> hpd_clks = devm_kcalloc (& pdev -> dev ,
486+ config -> hpd_clk_cnt ,
487+ sizeof (hdmi -> hpd_clks [0 ]),
488+ GFP_KERNEL );
489+ if (!hdmi -> hpd_clks )
490+ return - ENOMEM ;
491+
492+ for (i = 0 ; i < config -> hpd_clk_cnt ; i ++ ) {
493+ struct clk * clk ;
494+
495+ clk = msm_clk_get (pdev , config -> hpd_clk_names [i ]);
496+ if (IS_ERR (clk ))
497+ return dev_err_probe (dev , PTR_ERR (clk ),
498+ "failed to get hpd clk: %s\n" ,
499+ config -> hpd_clk_names [i ]);
500+
501+ hdmi -> hpd_clks [i ] = clk ;
502+ }
503+
504+ hdmi -> pwr_clks = devm_kcalloc (& pdev -> dev ,
505+ config -> pwr_clk_cnt ,
506+ sizeof (hdmi -> pwr_clks [0 ]),
507+ GFP_KERNEL );
508+ if (!hdmi -> pwr_clks )
509+ return - ENOMEM ;
510+
511+ for (i = 0 ; i < config -> pwr_clk_cnt ; i ++ ) {
512+ struct clk * clk ;
513+
514+ clk = msm_clk_get (pdev , config -> pwr_clk_names [i ]);
515+ if (IS_ERR (clk ))
516+ return dev_err_probe (dev , PTR_ERR (clk ),
517+ "failed to get pwr clk: %s\n" ,
518+ config -> pwr_clk_names [i ]);
519+
520+ hdmi -> pwr_clks [i ] = clk ;
521+ }
522+
523+ hdmi -> hpd_gpiod = devm_gpiod_get_optional (& pdev -> dev , "hpd" , GPIOD_IN );
524+ /* This will catch e.g. -EPROBE_DEFER */
525+ if (IS_ERR (hdmi -> hpd_gpiod ))
526+ return dev_err_probe (dev , PTR_ERR (hdmi -> hpd_gpiod ),
527+ "failed to get hpd gpio\n" );
528+
529+ if (!hdmi -> hpd_gpiod )
530+ DBG ("failed to get HPD gpio" );
531+
532+ if (hdmi -> hpd_gpiod )
533+ gpiod_set_consumer_name (hdmi -> hpd_gpiod , "HDMI_HPD" );
534+
535+ ret = devm_pm_runtime_enable (& pdev -> dev );
536+ if (ret )
537+ return ret ;
538+
539+ platform_set_drvdata (pdev , hdmi );
540+
569541 return component_add (& pdev -> dev , & msm_hdmi_ops );
570542}
571543
0 commit comments