aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/shmobile/shmob_drm_crtc.c7
-rw-r--r--drivers/gpu/drm/shmobile/shmob_drm_drv.c204
2 files changed, 104 insertions, 107 deletions
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
index 445476551695..8fd1c0c798a1 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
@@ -692,13 +692,10 @@ int shmob_drm_connector_create(struct shmob_drm_device *sdev,
692 return ret; 692 return ret;
693 693
694 drm_connector_helper_add(connector, &connector_helper_funcs); 694 drm_connector_helper_add(connector, &connector_helper_funcs);
695 ret = drm_connector_register(connector);
696 if (ret < 0)
697 goto err_cleanup;
698 695
699 ret = shmob_drm_backlight_init(&sdev->connector); 696 ret = shmob_drm_backlight_init(&sdev->connector);
700 if (ret < 0) 697 if (ret < 0)
701 goto err_sysfs; 698 goto err_cleanup;
702 699
703 ret = drm_mode_connector_attach_encoder(connector, encoder); 700 ret = drm_mode_connector_attach_encoder(connector, encoder);
704 if (ret < 0) 701 if (ret < 0)
@@ -712,8 +709,6 @@ int shmob_drm_connector_create(struct shmob_drm_device *sdev,
712 709
713err_backlight: 710err_backlight:
714 shmob_drm_backlight_exit(&sdev->connector); 711 shmob_drm_backlight_exit(&sdev->connector);
715err_sysfs:
716 drm_connector_unregister(connector);
717err_cleanup: 712err_cleanup:
718 drm_connector_cleanup(connector); 713 drm_connector_cleanup(connector);
719 return ret; 714 return ret;
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index 33cec3d42389..ec7a5eb809a2 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -104,100 +104,6 @@ static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev,
104 * DRM operations 104 * DRM operations
105 */ 105 */
106 106
107static void shmob_drm_unload(struct drm_device *dev)
108{
109 drm_kms_helper_poll_fini(dev);
110 drm_mode_config_cleanup(dev);
111 drm_vblank_cleanup(dev);
112 drm_irq_uninstall(dev);
113
114 dev->dev_private = NULL;
115}
116
117static int shmob_drm_load(struct drm_device *dev, unsigned long flags)
118{
119 struct shmob_drm_platform_data *pdata = dev->dev->platform_data;
120 struct platform_device *pdev = dev->platformdev;
121 struct shmob_drm_device *sdev;
122 struct resource *res;
123 unsigned int i;
124 int ret;
125
126 if (pdata == NULL) {
127 dev_err(dev->dev, "no platform data\n");
128 return -EINVAL;
129 }
130
131 sdev = devm_kzalloc(&pdev->dev, sizeof(*sdev), GFP_KERNEL);
132 if (sdev == NULL) {
133 dev_err(dev->dev, "failed to allocate private data\n");
134 return -ENOMEM;
135 }
136
137 sdev->dev = &pdev->dev;
138 sdev->pdata = pdata;
139 spin_lock_init(&sdev->irq_lock);
140
141 sdev->ddev = dev;
142 dev->dev_private = sdev;
143
144 /* I/O resources and clocks */
145 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
146 if (res == NULL) {
147 dev_err(&pdev->dev, "failed to get memory resource\n");
148 return -EINVAL;
149 }
150
151 sdev->mmio = devm_ioremap_nocache(&pdev->dev, res->start,
152 resource_size(res));
153 if (sdev->mmio == NULL) {
154 dev_err(&pdev->dev, "failed to remap memory resource\n");
155 return -ENOMEM;
156 }
157
158 ret = shmob_drm_setup_clocks(sdev, pdata->clk_source);
159 if (ret < 0)
160 return ret;
161
162 ret = shmob_drm_init_interface(sdev);
163 if (ret < 0)
164 return ret;
165
166 ret = shmob_drm_modeset_init(sdev);
167 if (ret < 0) {
168 dev_err(&pdev->dev, "failed to initialize mode setting\n");
169 return ret;
170 }
171
172 for (i = 0; i < 4; ++i) {
173 ret = shmob_drm_plane_create(sdev, i);
174 if (ret < 0) {
175 dev_err(&pdev->dev, "failed to create plane %u\n", i);
176 goto done;
177 }
178 }
179
180 ret = drm_vblank_init(dev, 1);
181 if (ret < 0) {
182 dev_err(&pdev->dev, "failed to initialize vblank\n");
183 goto done;
184 }
185
186 ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
187 if (ret < 0) {
188 dev_err(&pdev->dev, "failed to install IRQ handler\n");
189 goto done;
190 }
191
192 platform_set_drvdata(pdev, sdev);
193
194done:
195 if (ret)
196 shmob_drm_unload(dev);
197
198 return ret;
199}
200
201static irqreturn_t shmob_drm_irq(int irq, void *arg) 107static irqreturn_t shmob_drm_irq(int irq, void *arg)
202{ 108{
203 struct drm_device *dev = arg; 109 struct drm_device *dev = arg;
@@ -253,8 +159,6 @@ static const struct file_operations shmob_drm_fops = {
253static struct drm_driver shmob_drm_driver = { 159static struct drm_driver shmob_drm_driver = {
254 .driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET 160 .driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
255 | DRIVER_PRIME, 161 | DRIVER_PRIME,
256 .load = shmob_drm_load,
257 .unload = shmob_drm_unload,
258 .irq_handler = shmob_drm_irq, 162 .irq_handler = shmob_drm_irq,
259 .get_vblank_counter = drm_vblank_no_hw_counter, 163 .get_vblank_counter = drm_vblank_no_hw_counter,
260 .enable_vblank = shmob_drm_enable_vblank, 164 .enable_vblank = shmob_drm_enable_vblank,
@@ -317,18 +221,116 @@ static const struct dev_pm_ops shmob_drm_pm_ops = {
317 * Platform driver 221 * Platform driver
318 */ 222 */
319 223
320static int shmob_drm_probe(struct platform_device *pdev) 224static int shmob_drm_remove(struct platform_device *pdev)
321{ 225{
322 return drm_platform_init(&shmob_drm_driver, pdev); 226 struct shmob_drm_device *sdev = platform_get_drvdata(pdev);
227 struct drm_device *ddev = sdev->ddev;
228
229 drm_dev_unregister(ddev);
230 drm_kms_helper_poll_fini(ddev);
231 drm_mode_config_cleanup(ddev);
232 drm_irq_uninstall(ddev);
233 drm_dev_unref(ddev);
234
235 return 0;
323} 236}
324 237
325static int shmob_drm_remove(struct platform_device *pdev) 238static int shmob_drm_probe(struct platform_device *pdev)
326{ 239{
327 struct shmob_drm_device *sdev = platform_get_drvdata(pdev); 240 struct shmob_drm_platform_data *pdata = pdev->dev.platform_data;
241 struct shmob_drm_device *sdev;
242 struct drm_device *ddev;
243 struct resource *res;
244 unsigned int i;
245 int ret;
246
247 if (pdata == NULL) {
248 dev_err(&pdev->dev, "no platform data\n");
249 return -EINVAL;
250 }
328 251
329 drm_put_dev(sdev->ddev); 252 /*
253 * Allocate and initialize the driver private data, I/O resources and
254 * clocks.
255 */
256 sdev = devm_kzalloc(&pdev->dev, sizeof(*sdev), GFP_KERNEL);
257 if (sdev == NULL)
258 return -ENOMEM;
259
260 sdev->dev = &pdev->dev;
261 sdev->pdata = pdata;
262 spin_lock_init(&sdev->irq_lock);
263
264 platform_set_drvdata(pdev, sdev);
265
266 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
267 sdev->mmio = devm_ioremap_resource(&pdev->dev, res);
268 if (sdev->mmio == NULL)
269 return -ENOMEM;
270
271 ret = shmob_drm_setup_clocks(sdev, pdata->clk_source);
272 if (ret < 0)
273 return ret;
274
275 ret = shmob_drm_init_interface(sdev);
276 if (ret < 0)
277 return ret;
278
279 /* Allocate and initialize the DRM device. */
280 ddev = drm_dev_alloc(&shmob_drm_driver, &pdev->dev);
281 if (IS_ERR(ddev))
282 return PTR_ERR(ddev);
283
284 sdev->ddev = ddev;
285 ddev->dev_private = sdev;
286
287 ret = shmob_drm_modeset_init(sdev);
288 if (ret < 0) {
289 dev_err(&pdev->dev, "failed to initialize mode setting\n");
290 goto err_free_drm_dev;
291 }
292
293 for (i = 0; i < 4; ++i) {
294 ret = shmob_drm_plane_create(sdev, i);
295 if (ret < 0) {
296 dev_err(&pdev->dev, "failed to create plane %u\n", i);
297 goto err_modeset_cleanup;
298 }
299 }
300
301 ret = drm_vblank_init(ddev, 1);
302 if (ret < 0) {
303 dev_err(&pdev->dev, "failed to initialize vblank\n");
304 goto err_modeset_cleanup;
305 }
306
307 ret = drm_irq_install(ddev, platform_get_irq(pdev, 0));
308 if (ret < 0) {
309 dev_err(&pdev->dev, "failed to install IRQ handler\n");
310 goto err_vblank_cleanup;
311 }
312
313 /*
314 * Register the DRM device with the core and the connectors with
315 * sysfs.
316 */
317 ret = drm_dev_register(ddev, 0);
318 if (ret < 0)
319 goto err_irq_uninstall;
330 320
331 return 0; 321 return 0;
322
323err_irq_uninstall:
324 drm_irq_uninstall(ddev);
325err_vblank_cleanup:
326 drm_vblank_cleanup(ddev);
327err_modeset_cleanup:
328 drm_kms_helper_poll_fini(ddev);
329 drm_mode_config_cleanup(ddev);
330err_free_drm_dev:
331 drm_dev_unref(ddev);
332
333 return ret;
332} 334}
333 335
334static struct platform_driver shmob_drm_platform_driver = { 336static struct platform_driver shmob_drm_platform_driver = {