Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * linux/drivers/pcmcia/pxa2xx_palmtx.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Driver for Palm T|X PCMCIA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <mach/palmtx.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "soc_common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) static struct gpio palmtx_pcmcia_gpios[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	{ GPIO_NR_PALMTX_PCMCIA_POWER1,	GPIOF_INIT_LOW,	"PCMCIA Power 1" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	{ GPIO_NR_PALMTX_PCMCIA_POWER2,	GPIOF_INIT_LOW,	"PCMCIA Power 2" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	{ GPIO_NR_PALMTX_PCMCIA_RESET,	GPIOF_INIT_HIGH,"PCMCIA Reset" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static int palmtx_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	ret = gpio_request_array(palmtx_pcmcia_gpios,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 				ARRAY_SIZE(palmtx_pcmcia_gpios));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMTX_PCMCIA_READY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) static void palmtx_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	gpio_free_array(palmtx_pcmcia_gpios, ARRAY_SIZE(palmtx_pcmcia_gpios));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 					struct pcmcia_state *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	state->detect = 1; /* always inserted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	state->vs_3v  = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	state->vs_Xv  = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) palmtx_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 				const socket_state_t *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER2, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	gpio_set_value(GPIO_NR_PALMTX_PCMCIA_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			!!(state->flags & SS_RESET));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static struct pcmcia_low_level palmtx_pcmcia_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	.owner			= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	.first			= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	.nr			= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	.hw_init		= palmtx_pcmcia_hw_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	.hw_shutdown		= palmtx_pcmcia_hw_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	.socket_state		= palmtx_pcmcia_socket_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	.configure_socket	= palmtx_pcmcia_configure_socket,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static struct platform_device *palmtx_pcmcia_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) static int __init palmtx_pcmcia_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (!machine_is_palmtx())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	palmtx_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	if (!palmtx_pcmcia_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	ret = platform_device_add_data(palmtx_pcmcia_device, &palmtx_pcmcia_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 					sizeof(palmtx_pcmcia_ops));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		ret = platform_device_add(palmtx_pcmcia_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		platform_device_put(palmtx_pcmcia_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static void __exit palmtx_pcmcia_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	platform_device_unregister(palmtx_pcmcia_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) module_init(palmtx_pcmcia_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) module_exit(palmtx_pcmcia_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) MODULE_DESCRIPTION("PCMCIA support for Palm T|X");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) MODULE_ALIAS("platform:pxa2xx-pcmcia");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) MODULE_LICENSE("GPL");