^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) // Copyright 2010 Ben Dooks <ben-linux <at> fluff.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) // Helper for platform data setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "devs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "sdhci.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) void __init *s3c_set_platdata(void *pd, size_t pdsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) void *npd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) if (!pd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /* too early to use dev_name(), may not be registered */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) printk(KERN_ERR "%s: no platform data supplied\n", pdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) npd = kmemdup(pd, pdsize, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if (!npd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) pdev->dev.platform_data = npd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) return npd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct s3c_sdhci_platdata *set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) set->cd_type = pd->cd_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) set->ext_cd_init = pd->ext_cd_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) set->ext_cd_cleanup = pd->ext_cd_cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) set->ext_cd_gpio = pd->ext_cd_gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) if (pd->max_width)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) set->max_width = pd->max_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (pd->cfg_gpio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) set->cfg_gpio = pd->cfg_gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) if (pd->host_caps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) set->host_caps |= pd->host_caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) if (pd->host_caps2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) set->host_caps2 |= pd->host_caps2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) if (pd->pm_caps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) set->pm_caps |= pd->pm_caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }