xref: /openbmc/linux/arch/arm/mach-s3c/platformdata.c (revision cbecf716ca618fd44feda6bd9a64a8179d031fc5)
171b9114dSArnd Bergmann // SPDX-License-Identifier: GPL-2.0
271b9114dSArnd Bergmann //
371b9114dSArnd Bergmann // Copyright 2010 Ben Dooks <ben-linux <at> fluff.org>
471b9114dSArnd Bergmann //
571b9114dSArnd Bergmann // Helper for platform data setting
671b9114dSArnd Bergmann 
771b9114dSArnd Bergmann #include <linux/kernel.h>
871b9114dSArnd Bergmann #include <linux/slab.h>
971b9114dSArnd Bergmann #include <linux/string.h>
1071b9114dSArnd Bergmann #include <linux/platform_device.h>
1171b9114dSArnd Bergmann 
12*c6ff132dSArnd Bergmann #include "devs.h"
13*c6ff132dSArnd Bergmann #include "sdhci.h"
1471b9114dSArnd Bergmann 
s3c_set_platdata(void * pd,size_t pdsize,struct platform_device * pdev)1571b9114dSArnd Bergmann void __init *s3c_set_platdata(void *pd, size_t pdsize,
1671b9114dSArnd Bergmann 			      struct platform_device *pdev)
1771b9114dSArnd Bergmann {
1871b9114dSArnd Bergmann 	void *npd;
1971b9114dSArnd Bergmann 
2071b9114dSArnd Bergmann 	if (!pd) {
2171b9114dSArnd Bergmann 		/* too early to use dev_name(), may not be registered */
2271b9114dSArnd Bergmann 		printk(KERN_ERR "%s: no platform data supplied\n", pdev->name);
2371b9114dSArnd Bergmann 		return NULL;
2471b9114dSArnd Bergmann 	}
2571b9114dSArnd Bergmann 
2671b9114dSArnd Bergmann 	npd = kmemdup(pd, pdsize, GFP_KERNEL);
2771b9114dSArnd Bergmann 	if (!npd)
2871b9114dSArnd Bergmann 		return NULL;
2971b9114dSArnd Bergmann 
3071b9114dSArnd Bergmann 	pdev->dev.platform_data = npd;
3171b9114dSArnd Bergmann 	return npd;
3271b9114dSArnd Bergmann }
3371b9114dSArnd Bergmann 
s3c_sdhci_set_platdata(struct s3c_sdhci_platdata * pd,struct s3c_sdhci_platdata * set)3471b9114dSArnd Bergmann void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd,
3571b9114dSArnd Bergmann 			     struct s3c_sdhci_platdata *set)
3671b9114dSArnd Bergmann {
3771b9114dSArnd Bergmann 	set->cd_type = pd->cd_type;
3871b9114dSArnd Bergmann 	set->ext_cd_init = pd->ext_cd_init;
3971b9114dSArnd Bergmann 	set->ext_cd_cleanup = pd->ext_cd_cleanup;
4071b9114dSArnd Bergmann 	set->ext_cd_gpio = pd->ext_cd_gpio;
4171b9114dSArnd Bergmann 	set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert;
4271b9114dSArnd Bergmann 
4371b9114dSArnd Bergmann 	if (pd->max_width)
4471b9114dSArnd Bergmann 		set->max_width = pd->max_width;
4571b9114dSArnd Bergmann 	if (pd->cfg_gpio)
4671b9114dSArnd Bergmann 		set->cfg_gpio = pd->cfg_gpio;
4771b9114dSArnd Bergmann 	if (pd->host_caps)
4871b9114dSArnd Bergmann 		set->host_caps |= pd->host_caps;
4971b9114dSArnd Bergmann 	if (pd->host_caps2)
5071b9114dSArnd Bergmann 		set->host_caps2 |= pd->host_caps2;
5171b9114dSArnd Bergmann 	if (pd->pm_caps)
5271b9114dSArnd Bergmann 		set->pm_caps |= pd->pm_caps;
5371b9114dSArnd Bergmann }
54