Linux Audio

Check our new training course

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