Ben Dooks | 3911dab | 2010-06-10 12:57:15 +0900 | [diff] [blame] | 1 | /* 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> |
Paul Gortmaker | 3d46cce | 2011-07-31 18:16:56 -0400 | [diff] [blame] | 13 | #include <linux/slab.h> |
Ben Dooks | 3911dab | 2010-06-10 12:57:15 +0900 | [diff] [blame] | 14 | #include <linux/string.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | |
| 17 | #include <plat/devs.h> |
Banajit Goswami | 5e8e0a1 | 2011-08-18 20:32:01 +0900 | [diff] [blame] | 18 | #include <plat/sdhci.h> |
Ben Dooks | 3911dab | 2010-06-10 12:57:15 +0900 | [diff] [blame] | 19 | |
| 20 | void __init *s3c_set_platdata(void *pd, size_t pdsize, |
| 21 | struct platform_device *pdev) |
| 22 | { |
| 23 | void *npd; |
| 24 | |
| 25 | if (!pd) { |
| 26 | /* too early to use dev_name(), may not be registered */ |
| 27 | printk(KERN_ERR "%s: no platform data supplied\n", pdev->name); |
| 28 | return NULL; |
| 29 | } |
| 30 | |
| 31 | npd = kmemdup(pd, pdsize, GFP_KERNEL); |
| 32 | if (!npd) { |
| 33 | printk(KERN_ERR "%s: cannot clone platform data\n", pdev->name); |
| 34 | return NULL; |
| 35 | } |
| 36 | |
| 37 | pdev->dev.platform_data = npd; |
| 38 | return npd; |
| 39 | } |
Banajit Goswami | 5e8e0a1 | 2011-08-18 20:32:01 +0900 | [diff] [blame] | 40 | |
| 41 | void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd, |
| 42 | struct s3c_sdhci_platdata *set) |
| 43 | { |
| 44 | set->cd_type = pd->cd_type; |
| 45 | set->ext_cd_init = pd->ext_cd_init; |
| 46 | set->ext_cd_cleanup = pd->ext_cd_cleanup; |
| 47 | set->ext_cd_gpio = pd->ext_cd_gpio; |
| 48 | set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert; |
| 49 | |
| 50 | if (pd->max_width) |
| 51 | set->max_width = pd->max_width; |
| 52 | if (pd->cfg_gpio) |
| 53 | set->cfg_gpio = pd->cfg_gpio; |
Banajit Goswami | 5e8e0a1 | 2011-08-18 20:32:01 +0900 | [diff] [blame] | 54 | if (pd->host_caps) |
| 55 | set->host_caps |= pd->host_caps; |
Sangwook Lee | 92df954 | 2011-12-07 22:49:29 -0500 | [diff] [blame] | 56 | if (pd->pm_caps) |
| 57 | set->pm_caps |= pd->pm_caps; |
Banajit Goswami | 5e8e0a1 | 2011-08-18 20:32:01 +0900 | [diff] [blame] | 58 | if (pd->clk_type) |
| 59 | set->clk_type = pd->clk_type; |
| 60 | } |