Commit 1663b8fa authored by Martyn Welch's avatar Martyn Welch Committed by Greg Kroah-Hartman

staging: VME: Remove PIO2 driver

The PIO2 device is (as far as I know) no longer manufactured. I no longer
have access to the device and this seems unlikely to change. The only
changes to this driver in a long time have been as a result of API changes
else where. Time to remove it...
Signed-off-by: default avatarMartyn Welch <martyn.welch@collabora.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c40a45a4
......@@ -10,16 +10,3 @@ config VME_USER
To compile this driver as a module, choose M here. The module will
be called vme_user. If unsure, say N.
config VME_PIO2
tristate "GE PIO2 VME"
depends on STAGING && GPIOLIB
help
Say Y here to include support for the GE PIO2. The PIO2 is a 6U VME
slave card, implementing 32 solid-state relay switched IO lines, in
4 groups of 8. Each bank of IO lines is built to function as input,
output or both depending on the variant of the card.
To compile this driver as a module, choose M here. The module will
be called vme_pio2. If unsure, say N.
......@@ -3,6 +3,3 @@
#
obj-$(CONFIG_VME_USER) += vme_user.o
vme_pio2-objs := vme_pio2_cntr.o vme_pio2_gpio.o vme_pio2_core.o
obj-$(CONFIG_VME_PIO2) += vme_pio2.o
#ifndef _VME_PIO2_H_
#define _VME_PIO2_H_
#define PIO2_CARDS_MAX 32
#define PIO2_VARIANT_LENGTH 5
#define PIO2_NUM_CHANNELS 32
#define PIO2_NUM_IRQS 11
#define PIO2_NUM_CNTRS 6
#define PIO2_REGS_SIZE 0x40
#define PIO2_REGS_DATA0 0x0
#define PIO2_REGS_DATA1 0x1
#define PIO2_REGS_DATA2 0x2
#define PIO2_REGS_DATA3 0x3
static const int PIO2_REGS_DATA[4] = { PIO2_REGS_DATA0, PIO2_REGS_DATA1,
PIO2_REGS_DATA2, PIO2_REGS_DATA3 };
#define PIO2_REGS_INT_STAT0 0x8
#define PIO2_REGS_INT_STAT1 0x9
#define PIO2_REGS_INT_STAT2 0xa
#define PIO2_REGS_INT_STAT3 0xb
static const int PIO2_REGS_INT_STAT[4] = { PIO2_REGS_INT_STAT0,
PIO2_REGS_INT_STAT1,
PIO2_REGS_INT_STAT2,
PIO2_REGS_INT_STAT3 };
#define PIO2_REGS_INT_STAT_CNTR 0xc
#define PIO2_REGS_INT_MASK0 0x10
#define PIO2_REGS_INT_MASK1 0x11
#define PIO2_REGS_INT_MASK2 0x12
#define PIO2_REGS_INT_MASK3 0x13
#define PIO2_REGS_INT_MASK4 0x14
#define PIO2_REGS_INT_MASK5 0x15
#define PIO2_REGS_INT_MASK6 0x16
#define PIO2_REGS_INT_MASK7 0x17
static const int PIO2_REGS_INT_MASK[8] = { PIO2_REGS_INT_MASK0,
PIO2_REGS_INT_MASK1,
PIO2_REGS_INT_MASK2,
PIO2_REGS_INT_MASK3,
PIO2_REGS_INT_MASK4,
PIO2_REGS_INT_MASK5,
PIO2_REGS_INT_MASK6,
PIO2_REGS_INT_MASK7 };
#define PIO2_REGS_CTRL 0x18
#define PIO2_REGS_VME_VECTOR 0x19
#define PIO2_REGS_CNTR0 0x20
#define PIO2_REGS_CNTR1 0x22
#define PIO2_REGS_CNTR2 0x24
#define PIO2_REGS_CTRL_WRD0 0x26
#define PIO2_REGS_CNTR3 0x28
#define PIO2_REGS_CNTR4 0x2a
#define PIO2_REGS_CNTR5 0x2c
#define PIO2_REGS_CTRL_WRD1 0x2e
#define PIO2_REGS_ID 0x30
/* PIO2_REGS_DATAx (0x0 - 0x3) */
static const int PIO2_CHANNEL_BANK[32] = { 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3 };
#define PIO2_CHANNEL0_BIT BIT(0)
#define PIO2_CHANNEL1_BIT BIT(1)
#define PIO2_CHANNEL2_BIT BIT(2)
#define PIO2_CHANNEL3_BIT BIT(3)
#define PIO2_CHANNEL4_BIT BIT(4)
#define PIO2_CHANNEL5_BIT BIT(5)
#define PIO2_CHANNEL6_BIT BIT(6)
#define PIO2_CHANNEL7_BIT BIT(7)
#define PIO2_CHANNEL8_BIT BIT(0)
#define PIO2_CHANNEL9_BIT BIT(1)
#define PIO2_CHANNEL10_BIT BIT(2)
#define PIO2_CHANNEL11_BIT BIT(3)
#define PIO2_CHANNEL12_BIT BIT(4)
#define PIO2_CHANNEL13_BIT BIT(5)
#define PIO2_CHANNEL14_BIT BIT(6)
#define PIO2_CHANNEL15_BIT BIT(7)
#define PIO2_CHANNEL16_BIT BIT(0)
#define PIO2_CHANNEL17_BIT BIT(1)
#define PIO2_CHANNEL18_BIT BIT(2)
#define PIO2_CHANNEL19_BIT BIT(3)
#define PIO2_CHANNEL20_BIT BIT(4)
#define PIO2_CHANNEL21_BIT BIT(5)
#define PIO2_CHANNEL22_BIT BIT(6)
#define PIO2_CHANNEL23_BIT BIT(7)
#define PIO2_CHANNEL24_BIT BIT(0)
#define PIO2_CHANNEL25_BIT BIT(1)
#define PIO2_CHANNEL26_BIT BIT(2)
#define PIO2_CHANNEL27_BIT BIT(3)
#define PIO2_CHANNEL28_BIT BIT(4)
#define PIO2_CHANNEL29_BIT BIT(5)
#define PIO2_CHANNEL30_BIT BIT(6)
#define PIO2_CHANNEL31_BIT BIT(7)
static const int PIO2_CHANNEL_BIT[32] = { PIO2_CHANNEL0_BIT, PIO2_CHANNEL1_BIT,
PIO2_CHANNEL2_BIT, PIO2_CHANNEL3_BIT,
PIO2_CHANNEL4_BIT, PIO2_CHANNEL5_BIT,
PIO2_CHANNEL6_BIT, PIO2_CHANNEL7_BIT,
PIO2_CHANNEL8_BIT, PIO2_CHANNEL9_BIT,
PIO2_CHANNEL10_BIT, PIO2_CHANNEL11_BIT,
PIO2_CHANNEL12_BIT, PIO2_CHANNEL13_BIT,
PIO2_CHANNEL14_BIT, PIO2_CHANNEL15_BIT,
PIO2_CHANNEL16_BIT, PIO2_CHANNEL17_BIT,
PIO2_CHANNEL18_BIT, PIO2_CHANNEL19_BIT,
PIO2_CHANNEL20_BIT, PIO2_CHANNEL21_BIT,
PIO2_CHANNEL22_BIT, PIO2_CHANNEL23_BIT,
PIO2_CHANNEL24_BIT, PIO2_CHANNEL25_BIT,
PIO2_CHANNEL26_BIT, PIO2_CHANNEL27_BIT,
PIO2_CHANNEL28_BIT, PIO2_CHANNEL29_BIT,
PIO2_CHANNEL30_BIT, PIO2_CHANNEL31_BIT
};
/* PIO2_REGS_INT_STAT_CNTR (0xc) */
#define PIO2_COUNTER0 BIT(0)
#define PIO2_COUNTER1 BIT(1)
#define PIO2_COUNTER2 BIT(2)
#define PIO2_COUNTER3 BIT(3)
#define PIO2_COUNTER4 BIT(4)
#define PIO2_COUNTER5 BIT(5)
static const int PIO2_COUNTER[6] = { PIO2_COUNTER0, PIO2_COUNTER1,
PIO2_COUNTER2, PIO2_COUNTER3,
PIO2_COUNTER4, PIO2_COUNTER5 };
/* PIO2_REGS_CTRL (0x18) */
#define PIO2_VME_INT_MASK 0x7
#define PIO2_LED BIT(6)
#define PIO2_LOOP BIT(7)
/* PIO2_REGS_VME_VECTOR (0x19) */
#define PIO2_VME_VECTOR_SPUR 0x0
#define PIO2_VME_VECTOR_BANK0 0x1
#define PIO2_VME_VECTOR_BANK1 0x2
#define PIO2_VME_VECTOR_BANK2 0x3
#define PIO2_VME_VECTOR_BANK3 0x4
#define PIO2_VME_VECTOR_CNTR0 0x5
#define PIO2_VME_VECTOR_CNTR1 0x6
#define PIO2_VME_VECTOR_CNTR2 0x7
#define PIO2_VME_VECTOR_CNTR3 0x8
#define PIO2_VME_VECTOR_CNTR4 0x9
#define PIO2_VME_VECTOR_CNTR5 0xa
#define PIO2_VME_VECTOR_MASK 0xf0
static const int PIO2_VECTOR_BANK[4] = { PIO2_VME_VECTOR_BANK0,
PIO2_VME_VECTOR_BANK1,
PIO2_VME_VECTOR_BANK2,
PIO2_VME_VECTOR_BANK3 };
static const int PIO2_VECTOR_CNTR[6] = { PIO2_VME_VECTOR_CNTR0,
PIO2_VME_VECTOR_CNTR1,
PIO2_VME_VECTOR_CNTR2,
PIO2_VME_VECTOR_CNTR3,
PIO2_VME_VECTOR_CNTR4,
PIO2_VME_VECTOR_CNTR5 };
/* PIO2_REGS_CNTRx (0x20 - 0x24 & 0x28 - 0x2c) */
static const int PIO2_CNTR_DATA[6] = { PIO2_REGS_CNTR0, PIO2_REGS_CNTR1,
PIO2_REGS_CNTR2, PIO2_REGS_CNTR3,
PIO2_REGS_CNTR4, PIO2_REGS_CNTR5 };
/* PIO2_REGS_CTRL_WRDx (0x26 & 0x2e) */
static const int PIO2_CNTR_CTRL[6] = { PIO2_REGS_CTRL_WRD0,
PIO2_REGS_CTRL_WRD0,
PIO2_REGS_CTRL_WRD0,
PIO2_REGS_CTRL_WRD1,
PIO2_REGS_CTRL_WRD1,
PIO2_REGS_CTRL_WRD1 };
#define PIO2_CNTR_SC_DEV0 0
#define PIO2_CNTR_SC_DEV1 (1 << 6)
#define PIO2_CNTR_SC_DEV2 (2 << 6)
#define PIO2_CNTR_SC_RDBACK (3 << 6)
static const int PIO2_CNTR_SC_DEV[6] = { PIO2_CNTR_SC_DEV0, PIO2_CNTR_SC_DEV1,
PIO2_CNTR_SC_DEV2, PIO2_CNTR_SC_DEV0,
PIO2_CNTR_SC_DEV1, PIO2_CNTR_SC_DEV2 };
#define PIO2_CNTR_RW_LATCH 0
#define PIO2_CNTR_RW_LSB (1 << 4)
#define PIO2_CNTR_RW_MSB (2 << 4)
#define PIO2_CNTR_RW_BOTH (3 << 4)
#define PIO2_CNTR_MODE0 0
#define PIO2_CNTR_MODE1 (1 << 1)
#define PIO2_CNTR_MODE2 (2 << 1)
#define PIO2_CNTR_MODE3 (3 << 1)
#define PIO2_CNTR_MODE4 (4 << 1)
#define PIO2_CNTR_MODE5 (5 << 1)
#define PIO2_CNTR_BCD 1
enum pio2_bank_config { NOFIT, INPUT, OUTPUT, BOTH };
enum pio2_int_config { NONE = 0, LOW2HIGH = 1, HIGH2LOW = 2, EITHER = 4 };
/* Bank configuration structure */
struct pio2_io_bank {
enum pio2_bank_config config;
u8 value;
enum pio2_int_config irq[8];
};
/* Counter configuration structure */
struct pio2_cntr {
int mode;
int count;
};
struct pio2_card {
int id;
int bus;
long base;
int irq_vector;
int irq_level;
char variant[6];
int led;
struct vme_dev *vdev;
struct vme_resource *window;
struct gpio_chip gc;
struct pio2_io_bank bank[4];
struct pio2_cntr cntr[6];
};
int pio2_cntr_reset(struct pio2_card *card);
int pio2_gpio_reset(struct pio2_card *card);
int pio2_gpio_init(struct pio2_card *card);
void pio2_gpio_exit(struct pio2_card *card);
#endif /* _VME_PIO2_H_ */
/*
* GE PIO2 Counter Driver
*
* Author: Martyn Welch <martyn.welch@ge.com>
* Copyright 2009 GE Intelligent Platforms Embedded Systems, Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The PIO-2 has 6 counters, currently this code just disables the interrupts
* and leaves them alone.
*
*/
#include <linux/device.h>
#include <linux/types.h>
#include <linux/gpio.h>
#include <linux/vme.h>
#include "vme_pio2.h"
static int pio2_cntr_irq_set(struct pio2_card *card, int id)
{
int retval;
u8 data;
data = PIO2_CNTR_SC_DEV[id] | PIO2_CNTR_RW_BOTH | card->cntr[id].mode;
retval = vme_master_write(card->window, &data, 1, PIO2_CNTR_CTRL[id]);
if (retval < 0)
return retval;
data = card->cntr[id].count & 0xFF;
retval = vme_master_write(card->window, &data, 1, PIO2_CNTR_DATA[id]);
if (retval < 0)
return retval;
data = (card->cntr[id].count >> 8) & 0xFF;
retval = vme_master_write(card->window, &data, 1, PIO2_CNTR_DATA[id]);
if (retval < 0)
return retval;
return 0;
}
int pio2_cntr_reset(struct pio2_card *card)
{
int i, retval = 0;
u8 reg;
/* Clear down all timers */
for (i = 0; i < 6; i++) {
card->cntr[i].mode = PIO2_CNTR_MODE5;
card->cntr[i].count = 0;
retval = pio2_cntr_irq_set(card, i);
if (retval < 0)
return retval;
}
/* Ensure all counter interrupts are cleared */
do {
retval = vme_master_read(card->window, &reg, 1,
PIO2_REGS_INT_STAT_CNTR);
if (retval < 0)
return retval;
} while (reg != 0);
return retval;
}
This diff is collapsed.
/*
* GE PIO2 GPIO Driver
*
* Author: Martyn Welch <martyn.welch@ge.com>
* Copyright 2009 GE Intelligent Platforms Embedded Systems, Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/ctype.h>
#include <linux/gpio/driver.h>
#include <linux/slab.h>
#include <linux/vme.h>
#include "vme_pio2.h"
static const char driver_name[] = "pio2_gpio";
static int pio2_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
u8 reg;
int retval;
struct pio2_card *card = gpiochip_get_data(chip);
if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == OUTPUT) |
(card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) {
dev_err(&card->vdev->dev, "Channel not available as input\n");
return 0;
}
retval = vme_master_read(card->window, &reg, 1,
PIO2_REGS_DATA[PIO2_CHANNEL_BANK[offset]]);
if (retval < 0) {
dev_err(&card->vdev->dev, "Unable to read from GPIO\n");
return 0;
}
/*
* Remember, input on channels configured as both input and output
* are inverted!
*/
if (reg & PIO2_CHANNEL_BIT[offset]) {
if (card->bank[PIO2_CHANNEL_BANK[offset]].config != BOTH)
return 0;
return 1;
}
if (card->bank[PIO2_CHANNEL_BANK[offset]].config != BOTH)
return 1;
return 0;
}
static void pio2_gpio_set(struct gpio_chip *chip,
unsigned int offset, int value)
{
u8 reg;
int retval;
struct pio2_card *card = gpiochip_get_data(chip);
if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == INPUT) |
(card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) {
dev_err(&card->vdev->dev, "Channel not available as output\n");
return;
}
if (value)
reg = card->bank[PIO2_CHANNEL_BANK[offset]].value |
PIO2_CHANNEL_BIT[offset];
else
reg = card->bank[PIO2_CHANNEL_BANK[offset]].value &
~PIO2_CHANNEL_BIT[offset];
retval = vme_master_write(card->window, &reg, 1,
PIO2_REGS_DATA[PIO2_CHANNEL_BANK[offset]]);
if (retval < 0) {
dev_err(&card->vdev->dev, "Unable to write to GPIO\n");
return;
}
card->bank[PIO2_CHANNEL_BANK[offset]].value = reg;
}
/* Directionality configured at board build - send appropriate response */
static int pio2_gpio_dir_in(struct gpio_chip *chip, unsigned int offset)
{
int data;
struct pio2_card *card = gpiochip_get_data(chip);
if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == OUTPUT) |
(card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) {
dev_err(&card->vdev->dev,
"Channel directionality not configurable at runtime\n");
data = -EINVAL;
} else {
data = 0;
}
return data;
}
/* Directionality configured at board build - send appropriate response */
static int pio2_gpio_dir_out(struct gpio_chip *chip,
unsigned int offset, int value)
{
int data;
struct pio2_card *card = gpiochip_get_data(chip);
if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == INPUT) |
(card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) {
dev_err(&card->vdev->dev,
"Channel directionality not configurable at runtime\n");
data = -EINVAL;
} else {
data = 0;
}
return data;
}
/*
* We return whether this has been successful - this is used in the probe to
* ensure we have a valid card.
*/
int pio2_gpio_reset(struct pio2_card *card)
{
int retval = 0;
int i, j;
u8 data = 0;
/* Zero output registers */
for (i = 0; i < 4; i++) {
retval = vme_master_write(card->window, &data, 1,
PIO2_REGS_DATA[i]);
if (retval < 0)
return retval;
card->bank[i].value = 0;
}
/* Set input interrupt masks */
for (i = 0; i < 4; i++) {
retval = vme_master_write(card->window, &data, 1,
PIO2_REGS_INT_MASK[i * 2]);
if (retval < 0)
return retval;
retval = vme_master_write(card->window, &data, 1,
PIO2_REGS_INT_MASK[(i * 2) + 1]);
if (retval < 0)
return retval;
for (j = 0; j < 8; j++)
card->bank[i].irq[j] = NONE;
}
/* Ensure all I/O interrupts are cleared */
for (i = 0; i < 4; i++) {
do {
retval = vme_master_read(card->window, &data, 1,
PIO2_REGS_INT_STAT[i]);
if (retval < 0)
return retval;
} while (data != 0);
}
return 0;
}
int pio2_gpio_init(struct pio2_card *card)
{
int retval = 0;
char *label;
label = kasprintf(GFP_KERNEL,
"%s@%s", driver_name, dev_name(&card->vdev->dev));
if (!label)
return -ENOMEM;
card->gc.label = label;
card->gc.ngpio = PIO2_NUM_CHANNELS;
/* Dynamic allocation of base */
card->gc.base = -1;
/* Setup pointers to chip functions */
card->gc.direction_input = pio2_gpio_dir_in;
card->gc.direction_output = pio2_gpio_dir_out;
card->gc.get = pio2_gpio_get;
card->gc.set = pio2_gpio_set;
/* This function adds a memory mapped GPIO chip */
retval = gpiochip_add_data(&card->gc, card);
if (retval) {
dev_err(&card->vdev->dev, "Unable to register GPIO\n");
kfree(card->gc.label);
}
return retval;
};
void pio2_gpio_exit(struct pio2_card *card)
{
const char *label = card->gc.label;
gpiochip_remove(&card->gc);
kfree(label);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment