blob: 6de1a38259276de08a0b1dbe9835801fb5affba8 [file] [log] [blame]
Ben Dooks3911dab2010-06-10 12:57:15 +09001/* linux/arch/arm/plat-samsung/platformdata.c
2 *
3 * Copyright 2010 Ben Dooks <ben-linux <at> fluff.org>
4 *
5 * Helper for platform data setting
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <linux/kernel.h>
13#include <linux/string.h>
14#include <linux/platform_device.h>
15
16#include <plat/devs.h>
Banajit Goswami5e8e0a12011-08-18 20:32:01 +090017#include <plat/sdhci.h>
Ben Dooks3911dab2010-06-10 12:57:15 +090018
19void __init *s3c_set_platdata(void *pd, size_t pdsize,
20 struct platform_device *pdev)
21{
22 void *npd;
23
24 if (!pd) {
25 /* too early to use dev_name(), may not be registered */
26 printk(KERN_ERR "%s: no platform data supplied\n", pdev->name);
27 return NULL;
28 }
29
30 npd = kmemdup(pd, pdsize, GFP_KERNEL);
31 if (!npd) {
32 printk(KERN_ERR "%s: cannot clone platform data\n", pdev->name);
33 return NULL;
34 }
35
36 pdev->dev.platform_data = npd;
37 return npd;
38}
Banajit Goswami5e8e0a12011-08-18 20:32:01 +090039
40void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd,
41 struct s3c_sdhci_platdata *set)
42{
43 set->cd_type = pd->cd_type;
44 set->ext_cd_init = pd->ext_cd_init;
45 set->ext_cd_cleanup = pd->ext_cd_cleanup;
46 set->ext_cd_gpio = pd->ext_cd_gpio;
47 set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert;
48
49 if (pd->max_width)
50 set->max_width = pd->max_width;
51 if (pd->cfg_gpio)
52 set->cfg_gpio = pd->cfg_gpio;
53 if (pd->cfg_card)
54 set->cfg_card = pd->cfg_card;
55 if (pd->host_caps)
56 set->host_caps |= pd->host_caps;
57 if (pd->clk_type)
58 set->clk_type = pd->clk_type;
59}