2005-09-11 09:26:31 +00:00
|
|
|
/*
|
|
|
|
* linux/drivers/mfd/ucb1x00-core.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 Russell King, All Rights Reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The UCB1x00 core driver provides basic services for handling IO,
|
|
|
|
* the ADC, interrupts, and accessing registers. It is designed
|
|
|
|
* such that everything goes through this layer, thereby providing
|
|
|
|
* a consistent locking methodology, as well as allowing the drivers
|
|
|
|
* to be used on other non-MCP-enabled hardware platforms.
|
|
|
|
*
|
|
|
|
* Note that all locks are private to this file. Nothing else may
|
|
|
|
* touch them.
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
2009-10-07 13:09:06 +00:00
|
|
|
#include <linux/sched.h>
|
2005-09-11 09:26:31 +00:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/device.h>
|
2006-01-12 18:43:35 +00:00
|
|
|
#include <linux/mutex.h>
|
2009-02-10 13:54:57 +00:00
|
|
|
#include <linux/mfd/ucb1x00.h>
|
2012-01-21 16:36:30 +00:00
|
|
|
#include <linux/pm.h>
|
2009-02-10 13:50:56 +00:00
|
|
|
#include <linux/gpio.h>
|
2005-09-11 09:26:31 +00:00
|
|
|
|
2006-01-12 18:43:35 +00:00
|
|
|
static DEFINE_MUTEX(ucb1x00_mutex);
|
2005-09-11 09:26:31 +00:00
|
|
|
static LIST_HEAD(ucb1x00_drivers);
|
|
|
|
static LIST_HEAD(ucb1x00_devices);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ucb1x00_io_set_dir - set IO direction
|
|
|
|
* @ucb: UCB1x00 structure describing chip
|
|
|
|
* @in: bitfield of IO pins to be set as inputs
|
|
|
|
* @out: bitfield of IO pins to be set as outputs
|
|
|
|
*
|
|
|
|
* Set the IO direction of the ten general purpose IO pins on
|
|
|
|
* the UCB1x00 chip. The @in bitfield has priority over the
|
|
|
|
* @out bitfield, in that if you specify a pin as both input
|
|
|
|
* and output, it will end up as an input.
|
|
|
|
*
|
|
|
|
* ucb1x00_enable must have been called to enable the comms
|
|
|
|
* before using this function.
|
|
|
|
*
|
|
|
|
* This function takes a spinlock, disabling interrupts.
|
|
|
|
*/
|
|
|
|
void ucb1x00_io_set_dir(struct ucb1x00 *ucb, unsigned int in, unsigned int out)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ucb->io_lock, flags);
|
|
|
|
ucb->io_dir |= out;
|
|
|
|
ucb->io_dir &= ~in;
|
|
|
|
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir);
|
|
|
|
spin_unlock_irqrestore(&ucb->io_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ucb1x00_io_write - set or clear IO outputs
|
|
|
|
* @ucb: UCB1x00 structure describing chip
|
|
|
|
* @set: bitfield of IO pins to set to logic '1'
|
|
|
|
* @clear: bitfield of IO pins to set to logic '0'
|
|
|
|
*
|
|
|
|
* Set the IO output state of the specified IO pins. The value
|
|
|
|
* is retained if the pins are subsequently configured as inputs.
|
|
|
|
* The @clear bitfield has priority over the @set bitfield -
|
|
|
|
* outputs will be cleared.
|
|
|
|
*
|
|
|
|
* ucb1x00_enable must have been called to enable the comms
|
|
|
|
* before using this function.
|
|
|
|
*
|
|
|
|
* This function takes a spinlock, disabling interrupts.
|
|
|
|
*/
|
|
|
|
void ucb1x00_io_write(struct ucb1x00 *ucb, unsigned int set, unsigned int clear)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ucb->io_lock, flags);
|
|
|
|
ucb->io_out |= set;
|
|
|
|
ucb->io_out &= ~clear;
|
|
|
|
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out);
|
|
|
|
spin_unlock_irqrestore(&ucb->io_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ucb1x00_io_read - read the current state of the IO pins
|
|
|
|
* @ucb: UCB1x00 structure describing chip
|
|
|
|
*
|
|
|
|
* Return a bitfield describing the logic state of the ten
|
|
|
|
* general purpose IO pins.
|
|
|
|
*
|
|
|
|
* ucb1x00_enable must have been called to enable the comms
|
|
|
|
* before using this function.
|
|
|
|
*
|
2012-01-21 09:33:38 +00:00
|
|
|
* This function does not take any mutexes or spinlocks.
|
2005-09-11 09:26:31 +00:00
|
|
|
*/
|
|
|
|
unsigned int ucb1x00_io_read(struct ucb1x00 *ucb)
|
|
|
|
{
|
|
|
|
return ucb1x00_reg_read(ucb, UCB_IO_DATA);
|
|
|
|
}
|
|
|
|
|
2009-02-10 13:50:56 +00:00
|
|
|
static void ucb1x00_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
|
|
|
{
|
|
|
|
struct ucb1x00 *ucb = container_of(chip, struct ucb1x00, gpio);
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ucb->io_lock, flags);
|
|
|
|
if (value)
|
|
|
|
ucb->io_out |= 1 << offset;
|
|
|
|
else
|
|
|
|
ucb->io_out &= ~(1 << offset);
|
|
|
|
|
2012-01-21 18:13:20 +00:00
|
|
|
ucb1x00_enable(ucb);
|
2009-02-10 13:50:56 +00:00
|
|
|
ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out);
|
2012-01-21 18:13:20 +00:00
|
|
|
ucb1x00_disable(ucb);
|
2009-02-10 13:50:56 +00:00
|
|
|
spin_unlock_irqrestore(&ucb->io_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ucb1x00_gpio_get(struct gpio_chip *chip, unsigned offset)
|
|
|
|
{
|
|
|
|
struct ucb1x00 *ucb = container_of(chip, struct ucb1x00, gpio);
|
2012-01-21 18:13:20 +00:00
|
|
|
unsigned val;
|
|
|
|
|
|
|
|
ucb1x00_enable(ucb);
|
|
|
|
val = ucb1x00_reg_read(ucb, UCB_IO_DATA);
|
|
|
|
ucb1x00_disable(ucb);
|
|
|
|
|
|
|
|
return val & (1 << offset);
|
2009-02-10 13:50:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ucb1x00_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
|
|
|
|
{
|
|
|
|
struct ucb1x00 *ucb = container_of(chip, struct ucb1x00, gpio);
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ucb->io_lock, flags);
|
|
|
|
ucb->io_dir &= ~(1 << offset);
|
2012-01-21 18:13:20 +00:00
|
|
|
ucb1x00_enable(ucb);
|
2009-02-10 13:50:56 +00:00
|
|
|
ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir);
|
2012-01-21 18:13:20 +00:00
|
|
|
ucb1x00_disable(ucb);
|
2009-02-10 13:50:56 +00:00
|
|
|
spin_unlock_irqrestore(&ucb->io_lock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ucb1x00_gpio_direction_output(struct gpio_chip *chip, unsigned offset
|
|
|
|
, int value)
|
|
|
|
{
|
|
|
|
struct ucb1x00 *ucb = container_of(chip, struct ucb1x00, gpio);
|
|
|
|
unsigned long flags;
|
2012-01-21 18:21:50 +00:00
|
|
|
unsigned old, mask = 1 << offset;
|
2009-02-10 13:50:56 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&ucb->io_lock, flags);
|
2012-01-21 18:21:50 +00:00
|
|
|
old = ucb->io_out;
|
2009-02-10 13:50:56 +00:00
|
|
|
if (value)
|
2012-01-21 18:21:50 +00:00
|
|
|
ucb->io_out |= mask;
|
2009-02-10 13:50:56 +00:00
|
|
|
else
|
2012-01-21 18:21:50 +00:00
|
|
|
ucb->io_out &= ~mask;
|
|
|
|
|
2012-01-21 18:13:20 +00:00
|
|
|
ucb1x00_enable(ucb);
|
2012-01-21 18:21:50 +00:00
|
|
|
if (old != ucb->io_out)
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out);
|
|
|
|
|
|
|
|
if (!(ucb->io_dir & mask)) {
|
|
|
|
ucb->io_dir |= mask;
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir);
|
|
|
|
}
|
2012-01-21 18:13:20 +00:00
|
|
|
ucb1x00_disable(ucb);
|
2009-02-10 13:50:56 +00:00
|
|
|
spin_unlock_irqrestore(&ucb->io_lock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-09-11 09:26:31 +00:00
|
|
|
/*
|
|
|
|
* UCB1300 data sheet says we must:
|
|
|
|
* 1. enable ADC => 5us (including reference startup time)
|
|
|
|
* 2. select input => 51*tsibclk => 4.3us
|
|
|
|
* 3. start conversion => 102*tsibclk => 8.5us
|
|
|
|
* (tsibclk = 1/11981000)
|
|
|
|
* Period between SIB 128-bit frames = 10.7us
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ucb1x00_adc_enable - enable the ADC converter
|
|
|
|
* @ucb: UCB1x00 structure describing chip
|
|
|
|
*
|
|
|
|
* Enable the ucb1x00 and ADC converter on the UCB1x00 for use.
|
|
|
|
* Any code wishing to use the ADC converter must call this
|
|
|
|
* function prior to using it.
|
|
|
|
*
|
2012-01-21 09:33:38 +00:00
|
|
|
* This function takes the ADC mutex to prevent two or more
|
2005-09-11 09:26:31 +00:00
|
|
|
* concurrent uses, and therefore may sleep. As a result, it
|
|
|
|
* can only be called from process context, not interrupt
|
|
|
|
* context.
|
|
|
|
*
|
|
|
|
* You should release the ADC as soon as possible using
|
|
|
|
* ucb1x00_adc_disable.
|
|
|
|
*/
|
|
|
|
void ucb1x00_adc_enable(struct ucb1x00 *ucb)
|
|
|
|
{
|
2012-01-21 09:33:38 +00:00
|
|
|
mutex_lock(&ucb->adc_mutex);
|
2005-09-11 09:26:31 +00:00
|
|
|
|
|
|
|
ucb->adc_cr |= UCB_ADC_ENA;
|
|
|
|
|
|
|
|
ucb1x00_enable(ucb);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ucb1x00_adc_read - read the specified ADC channel
|
|
|
|
* @ucb: UCB1x00 structure describing chip
|
|
|
|
* @adc_channel: ADC channel mask
|
|
|
|
* @sync: wait for syncronisation pulse.
|
|
|
|
*
|
|
|
|
* Start an ADC conversion and wait for the result. Note that
|
|
|
|
* synchronised ADC conversions (via the ADCSYNC pin) must wait
|
|
|
|
* until the trigger is asserted and the conversion is finished.
|
|
|
|
*
|
|
|
|
* This function currently spins waiting for the conversion to
|
|
|
|
* complete (2 frames max without sync).
|
|
|
|
*
|
|
|
|
* If called for a synchronised ADC conversion, it may sleep
|
2012-01-21 09:33:38 +00:00
|
|
|
* with the ADC mutex held.
|
2005-09-11 09:26:31 +00:00
|
|
|
*/
|
|
|
|
unsigned int ucb1x00_adc_read(struct ucb1x00 *ucb, int adc_channel, int sync)
|
|
|
|
{
|
|
|
|
unsigned int val;
|
|
|
|
|
|
|
|
if (sync)
|
|
|
|
adc_channel |= UCB_ADC_SYNC_ENA;
|
|
|
|
|
|
|
|
ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr | adc_channel);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr | adc_channel | UCB_ADC_START);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
val = ucb1x00_reg_read(ucb, UCB_ADC_DATA);
|
|
|
|
if (val & UCB_ADC_DAT_VAL)
|
|
|
|
break;
|
|
|
|
/* yield to other processes */
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
|
|
schedule_timeout(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return UCB_ADC_DAT(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ucb1x00_adc_disable - disable the ADC converter
|
|
|
|
* @ucb: UCB1x00 structure describing chip
|
|
|
|
*
|
2012-01-21 09:33:38 +00:00
|
|
|
* Disable the ADC converter and release the ADC mutex.
|
2005-09-11 09:26:31 +00:00
|
|
|
*/
|
|
|
|
void ucb1x00_adc_disable(struct ucb1x00 *ucb)
|
|
|
|
{
|
|
|
|
ucb->adc_cr &= ~UCB_ADC_ENA;
|
|
|
|
ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr);
|
|
|
|
ucb1x00_disable(ucb);
|
|
|
|
|
2012-01-21 09:33:38 +00:00
|
|
|
mutex_unlock(&ucb->adc_mutex);
|
2005-09-11 09:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* UCB1x00 Interrupt handling.
|
|
|
|
*
|
|
|
|
* The UCB1x00 can generate interrupts when the SIBCLK is stopped.
|
|
|
|
* Since we need to read an internal register, we must re-enable
|
|
|
|
* SIBCLK to talk to the chip. We leave the clock running until
|
|
|
|
* we have finished processing all interrupts from the chip.
|
|
|
|
*/
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t ucb1x00_irq(int irqnr, void *devid)
|
2005-09-11 09:26:31 +00:00
|
|
|
{
|
|
|
|
struct ucb1x00 *ucb = devid;
|
|
|
|
struct ucb1x00_irq *irq;
|
|
|
|
unsigned int isr, i;
|
|
|
|
|
|
|
|
ucb1x00_enable(ucb);
|
|
|
|
isr = ucb1x00_reg_read(ucb, UCB_IE_STATUS);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_CLEAR, isr);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0);
|
|
|
|
|
|
|
|
for (i = 0, irq = ucb->irq_handler; i < 16 && isr; i++, isr >>= 1, irq++)
|
|
|
|
if (isr & 1 && irq->fn)
|
|
|
|
irq->fn(i, irq->devid);
|
|
|
|
ucb1x00_disable(ucb);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ucb1x00_hook_irq - hook a UCB1x00 interrupt
|
|
|
|
* @ucb: UCB1x00 structure describing chip
|
|
|
|
* @idx: interrupt index
|
|
|
|
* @fn: function to call when interrupt is triggered
|
|
|
|
* @devid: device id to pass to interrupt handler
|
|
|
|
*
|
|
|
|
* Hook the specified interrupt. You can only register one handler
|
|
|
|
* for each interrupt source. The interrupt source is not enabled
|
|
|
|
* by this function; use ucb1x00_enable_irq instead.
|
|
|
|
*
|
|
|
|
* Interrupt handlers will be called with other interrupts enabled.
|
|
|
|
*
|
|
|
|
* Returns zero on success, or one of the following errors:
|
|
|
|
* -EINVAL if the interrupt index is invalid
|
|
|
|
* -EBUSY if the interrupt has already been hooked
|
|
|
|
*/
|
|
|
|
int ucb1x00_hook_irq(struct ucb1x00 *ucb, unsigned int idx, void (*fn)(int, void *), void *devid)
|
|
|
|
{
|
|
|
|
struct ucb1x00_irq *irq;
|
|
|
|
int ret = -EINVAL;
|
|
|
|
|
|
|
|
if (idx < 16) {
|
|
|
|
irq = ucb->irq_handler + idx;
|
|
|
|
ret = -EBUSY;
|
|
|
|
|
|
|
|
spin_lock_irq(&ucb->lock);
|
|
|
|
if (irq->fn == NULL) {
|
|
|
|
irq->devid = devid;
|
|
|
|
irq->fn = fn;
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&ucb->lock);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ucb1x00_enable_irq - enable an UCB1x00 interrupt source
|
|
|
|
* @ucb: UCB1x00 structure describing chip
|
|
|
|
* @idx: interrupt index
|
|
|
|
* @edges: interrupt edges to enable
|
|
|
|
*
|
|
|
|
* Enable the specified interrupt to trigger on %UCB_RISING,
|
|
|
|
* %UCB_FALLING or both edges. The interrupt should have been
|
|
|
|
* hooked by ucb1x00_hook_irq.
|
|
|
|
*/
|
|
|
|
void ucb1x00_enable_irq(struct ucb1x00 *ucb, unsigned int idx, int edges)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (idx < 16) {
|
|
|
|
spin_lock_irqsave(&ucb->lock, flags);
|
|
|
|
|
|
|
|
ucb1x00_enable(ucb);
|
|
|
|
if (edges & UCB_RISING) {
|
|
|
|
ucb->irq_ris_enbl |= 1 << idx;
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_RIS, ucb->irq_ris_enbl);
|
|
|
|
}
|
|
|
|
if (edges & UCB_FALLING) {
|
|
|
|
ucb->irq_fal_enbl |= 1 << idx;
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_FAL, ucb->irq_fal_enbl);
|
|
|
|
}
|
|
|
|
ucb1x00_disable(ucb);
|
|
|
|
spin_unlock_irqrestore(&ucb->lock, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ucb1x00_disable_irq - disable an UCB1x00 interrupt source
|
|
|
|
* @ucb: UCB1x00 structure describing chip
|
|
|
|
* @edges: interrupt edges to disable
|
|
|
|
*
|
|
|
|
* Disable the specified interrupt triggering on the specified
|
|
|
|
* (%UCB_RISING, %UCB_FALLING or both) edges.
|
|
|
|
*/
|
|
|
|
void ucb1x00_disable_irq(struct ucb1x00 *ucb, unsigned int idx, int edges)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (idx < 16) {
|
|
|
|
spin_lock_irqsave(&ucb->lock, flags);
|
|
|
|
|
|
|
|
ucb1x00_enable(ucb);
|
|
|
|
if (edges & UCB_RISING) {
|
|
|
|
ucb->irq_ris_enbl &= ~(1 << idx);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_RIS, ucb->irq_ris_enbl);
|
|
|
|
}
|
|
|
|
if (edges & UCB_FALLING) {
|
|
|
|
ucb->irq_fal_enbl &= ~(1 << idx);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_FAL, ucb->irq_fal_enbl);
|
|
|
|
}
|
|
|
|
ucb1x00_disable(ucb);
|
|
|
|
spin_unlock_irqrestore(&ucb->lock, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ucb1x00_free_irq - disable and free the specified UCB1x00 interrupt
|
|
|
|
* @ucb: UCB1x00 structure describing chip
|
|
|
|
* @idx: interrupt index
|
|
|
|
* @devid: device id.
|
|
|
|
*
|
|
|
|
* Disable the interrupt source and remove the handler. devid must
|
|
|
|
* match the devid passed when hooking the interrupt.
|
|
|
|
*
|
|
|
|
* Returns zero on success, or one of the following errors:
|
|
|
|
* -EINVAL if the interrupt index is invalid
|
|
|
|
* -ENOENT if devid does not match
|
|
|
|
*/
|
|
|
|
int ucb1x00_free_irq(struct ucb1x00 *ucb, unsigned int idx, void *devid)
|
|
|
|
{
|
|
|
|
struct ucb1x00_irq *irq;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (idx >= 16)
|
|
|
|
goto bad;
|
|
|
|
|
|
|
|
irq = ucb->irq_handler + idx;
|
|
|
|
ret = -ENOENT;
|
|
|
|
|
|
|
|
spin_lock_irq(&ucb->lock);
|
|
|
|
if (irq->devid == devid) {
|
|
|
|
ucb->irq_ris_enbl &= ~(1 << idx);
|
|
|
|
ucb->irq_fal_enbl &= ~(1 << idx);
|
|
|
|
|
|
|
|
ucb1x00_enable(ucb);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_RIS, ucb->irq_ris_enbl);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_FAL, ucb->irq_fal_enbl);
|
|
|
|
ucb1x00_disable(ucb);
|
|
|
|
|
|
|
|
irq->fn = NULL;
|
|
|
|
irq->devid = NULL;
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&ucb->lock);
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
bad:
|
|
|
|
printk(KERN_ERR "Freeing bad UCB1x00 irq %d\n", idx);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ucb1x00_add_dev(struct ucb1x00 *ucb, struct ucb1x00_driver *drv)
|
|
|
|
{
|
|
|
|
struct ucb1x00_dev *dev;
|
|
|
|
int ret = -ENOMEM;
|
|
|
|
|
|
|
|
dev = kmalloc(sizeof(struct ucb1x00_dev), GFP_KERNEL);
|
|
|
|
if (dev) {
|
|
|
|
dev->ucb = ucb;
|
|
|
|
dev->drv = drv;
|
|
|
|
|
|
|
|
ret = drv->add(dev);
|
|
|
|
|
|
|
|
if (ret == 0) {
|
2012-01-21 15:35:01 +00:00
|
|
|
list_add_tail(&dev->dev_node, &ucb->devs);
|
|
|
|
list_add_tail(&dev->drv_node, &drv->devs);
|
2005-09-11 09:26:31 +00:00
|
|
|
} else {
|
|
|
|
kfree(dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ucb1x00_remove_dev(struct ucb1x00_dev *dev)
|
|
|
|
{
|
|
|
|
dev->drv->remove(dev);
|
|
|
|
list_del(&dev->dev_node);
|
|
|
|
list_del(&dev->drv_node);
|
|
|
|
kfree(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to probe our interrupt, rather than relying on lots of
|
|
|
|
* hard-coded machine dependencies. For reference, the expected
|
|
|
|
* IRQ mappings are:
|
|
|
|
*
|
|
|
|
* Machine Default IRQ
|
|
|
|
* adsbitsy IRQ_GPCIN4
|
|
|
|
* cerf IRQ_GPIO_UCB1200_IRQ
|
|
|
|
* flexanet IRQ_GPIO_GUI
|
|
|
|
* freebird IRQ_GPIO_FREEBIRD_UCB1300_IRQ
|
|
|
|
* graphicsclient ADS_EXT_IRQ(8)
|
|
|
|
* graphicsmaster ADS_EXT_IRQ(8)
|
|
|
|
* lart LART_IRQ_UCB1200
|
|
|
|
* omnimeter IRQ_GPIO23
|
|
|
|
* pfs168 IRQ_GPIO_UCB1300_IRQ
|
|
|
|
* simpad IRQ_GPIO_UCB1300_IRQ
|
|
|
|
* shannon SHANNON_IRQ_GPIO_IRQ_CODEC
|
|
|
|
* yopy IRQ_GPIO_UCB1200_IRQ
|
|
|
|
*/
|
|
|
|
static int ucb1x00_detect_irq(struct ucb1x00 *ucb)
|
|
|
|
{
|
|
|
|
unsigned long mask;
|
|
|
|
|
|
|
|
mask = probe_irq_on();
|
2006-06-26 14:26:13 +00:00
|
|
|
if (!mask) {
|
|
|
|
probe_irq_off(mask);
|
2005-09-11 09:26:31 +00:00
|
|
|
return NO_IRQ;
|
2006-06-26 14:26:13 +00:00
|
|
|
}
|
2005-09-11 09:26:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable the ADC interrupt.
|
|
|
|
*/
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_RIS, UCB_IE_ADC);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_FAL, UCB_IE_ADC);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0xffff);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cause an ADC interrupt.
|
|
|
|
*/
|
|
|
|
ucb1x00_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait for the conversion to complete.
|
|
|
|
*/
|
|
|
|
while ((ucb1x00_reg_read(ucb, UCB_ADC_DATA) & UCB_ADC_DAT_VAL) == 0);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_ADC_CR, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable and clear interrupt.
|
|
|
|
*/
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_RIS, 0);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_FAL, 0);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0xffff);
|
|
|
|
ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read triggered interrupt.
|
|
|
|
*/
|
|
|
|
return probe_irq_off(mask);
|
|
|
|
}
|
|
|
|
|
2007-09-25 00:03:03 +00:00
|
|
|
static void ucb1x00_release(struct device *dev)
|
2005-10-10 17:22:17 +00:00
|
|
|
{
|
|
|
|
struct ucb1x00 *ucb = classdev_to_ucb1x00(dev);
|
|
|
|
kfree(ucb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct class ucb1x00_class = {
|
|
|
|
.name = "ucb1x00",
|
2007-09-25 00:03:03 +00:00
|
|
|
.dev_release = ucb1x00_release,
|
2005-10-10 17:22:17 +00:00
|
|
|
};
|
|
|
|
|
2005-09-11 09:26:31 +00:00
|
|
|
static int ucb1x00_probe(struct mcp *mcp)
|
|
|
|
{
|
2012-01-22 19:02:25 +00:00
|
|
|
struct ucb1x00_plat_data *pdata = mcp->attached_device.platform_data;
|
2005-09-11 09:26:31 +00:00
|
|
|
struct ucb1x00_driver *drv;
|
2012-01-22 19:02:25 +00:00
|
|
|
struct ucb1x00 *ucb;
|
2005-09-11 09:26:31 +00:00
|
|
|
unsigned int id;
|
|
|
|
int ret = -ENODEV;
|
2009-02-10 13:50:56 +00:00
|
|
|
int temp;
|
2005-09-11 09:26:31 +00:00
|
|
|
|
2012-01-22 19:02:25 +00:00
|
|
|
/* Tell the platform to deassert the UCB1x00 reset */
|
|
|
|
if (pdata && pdata->reset)
|
|
|
|
pdata->reset(UCB_RST_PROBE);
|
|
|
|
|
2005-09-11 09:26:31 +00:00
|
|
|
mcp_enable(mcp);
|
|
|
|
id = mcp_reg_read(mcp, UCB_ID);
|
2012-01-21 18:24:17 +00:00
|
|
|
mcp_disable(mcp);
|
2005-09-11 09:26:31 +00:00
|
|
|
|
2012-01-20 17:38:58 +00:00
|
|
|
if (id != UCB_ID_1200 && id != UCB_ID_1300 && id != UCB_ID_TC35143) {
|
|
|
|
printk(KERN_WARNING "UCB1x00 ID not found: %04x\n", id);
|
2012-01-21 18:24:17 +00:00
|
|
|
goto out;
|
2005-09-11 09:26:31 +00:00
|
|
|
}
|
|
|
|
|
some kmalloc/memset ->kzalloc (tree wide)
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
Here is a short excerpt of the semantic patch performing
this transformation:
@@
type T2;
expression x;
identifier f,fld;
expression E;
expression E1,E2;
expression e1,e2,e3,y;
statement S;
@@
x =
- kmalloc
+ kzalloc
(E1,E2)
... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
- memset((T2)x,0,E1);
@@
expression E1,E2,E3;
@@
- kzalloc(E1 * E2,E3)
+ kcalloc(E1,E2,E3)
[akpm@linux-foundation.org: get kcalloc args the right way around]
Signed-off-by: Yoann Padioleau <padator@wanadoo.fr>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Acked-by: Russell King <rmk@arm.linux.org.uk>
Cc: Bryan Wu <bryan.wu@analog.com>
Acked-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>
Acked-by: Roland Dreier <rolandd@cisco.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Acked-by: Pierre Ossman <drzeus-list@drzeus.cx>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: "David S. Miller" <davem@davemloft.net>
Acked-by: Greg KH <greg@kroah.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-19 08:49:03 +00:00
|
|
|
ucb = kzalloc(sizeof(struct ucb1x00), GFP_KERNEL);
|
2005-09-11 09:26:31 +00:00
|
|
|
ret = -ENOMEM;
|
|
|
|
if (!ucb)
|
2012-01-21 18:24:17 +00:00
|
|
|
goto out;
|
2005-09-11 09:26:31 +00:00
|
|
|
|
2012-01-21 14:45:17 +00:00
|
|
|
device_initialize(&ucb->dev);
|
2007-09-25 00:03:03 +00:00
|
|
|
ucb->dev.class = &ucb1x00_class;
|
|
|
|
ucb->dev.parent = &mcp->attached_device;
|
2012-01-20 17:38:58 +00:00
|
|
|
dev_set_name(&ucb->dev, "ucb1x00");
|
2005-09-11 09:26:31 +00:00
|
|
|
|
|
|
|
spin_lock_init(&ucb->lock);
|
|
|
|
spin_lock_init(&ucb->io_lock);
|
2012-01-21 09:33:38 +00:00
|
|
|
mutex_init(&ucb->adc_mutex);
|
2005-09-11 09:26:31 +00:00
|
|
|
|
2012-01-20 17:38:58 +00:00
|
|
|
ucb->id = id;
|
2005-09-11 09:26:31 +00:00
|
|
|
ucb->mcp = mcp;
|
2012-01-21 14:45:17 +00:00
|
|
|
|
|
|
|
ret = device_add(&ucb->dev);
|
|
|
|
if (ret)
|
|
|
|
goto err_dev_add;
|
|
|
|
|
2012-01-21 18:24:17 +00:00
|
|
|
ucb1x00_enable(ucb);
|
2005-09-11 09:26:31 +00:00
|
|
|
ucb->irq = ucb1x00_detect_irq(ucb);
|
2012-01-21 18:24:17 +00:00
|
|
|
ucb1x00_disable(ucb);
|
2005-09-11 09:26:31 +00:00
|
|
|
if (ucb->irq == NO_IRQ) {
|
2012-01-21 14:45:17 +00:00
|
|
|
dev_err(&ucb->dev, "IRQ probe failed\n");
|
2005-09-11 09:26:31 +00:00
|
|
|
ret = -ENODEV;
|
2012-01-21 14:45:17 +00:00
|
|
|
goto err_no_irq;
|
2005-09-11 09:26:31 +00:00
|
|
|
}
|
|
|
|
|
2009-02-10 13:50:56 +00:00
|
|
|
ucb->gpio.base = -1;
|
2012-01-20 22:13:52 +00:00
|
|
|
if (pdata && pdata->gpio_base) {
|
2009-02-10 13:50:56 +00:00
|
|
|
ucb->gpio.label = dev_name(&ucb->dev);
|
2012-01-21 14:47:00 +00:00
|
|
|
ucb->gpio.dev = &ucb->dev;
|
|
|
|
ucb->gpio.owner = THIS_MODULE;
|
2012-01-20 22:13:52 +00:00
|
|
|
ucb->gpio.base = pdata->gpio_base;
|
2009-02-10 13:50:56 +00:00
|
|
|
ucb->gpio.ngpio = 10;
|
|
|
|
ucb->gpio.set = ucb1x00_gpio_set;
|
|
|
|
ucb->gpio.get = ucb1x00_gpio_get;
|
|
|
|
ucb->gpio.direction_input = ucb1x00_gpio_direction_input;
|
|
|
|
ucb->gpio.direction_output = ucb1x00_gpio_direction_output;
|
|
|
|
ret = gpiochip_add(&ucb->gpio);
|
|
|
|
if (ret)
|
2012-01-21 14:45:17 +00:00
|
|
|
goto err_gpio_add;
|
2009-02-10 13:50:56 +00:00
|
|
|
} else
|
|
|
|
dev_info(&ucb->dev, "gpio_base not set so no gpiolib support");
|
|
|
|
|
2006-07-02 02:29:38 +00:00
|
|
|
ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING,
|
2012-01-20 17:38:58 +00:00
|
|
|
"UCB1x00", ucb);
|
2005-09-11 09:26:31 +00:00
|
|
|
if (ret) {
|
2012-01-21 14:45:17 +00:00
|
|
|
dev_err(&ucb->dev, "ucb1x00: unable to grab irq%d: %d\n",
|
2012-01-20 17:38:58 +00:00
|
|
|
ucb->irq, ret);
|
2012-01-21 14:45:17 +00:00
|
|
|
goto err_irq;
|
2005-09-11 09:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mcp_set_drvdata(mcp, ucb);
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&ucb->devs);
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_lock(&ucb1x00_mutex);
|
2012-01-21 15:35:01 +00:00
|
|
|
list_add_tail(&ucb->node, &ucb1x00_devices);
|
2005-09-11 09:26:31 +00:00
|
|
|
list_for_each_entry(drv, &ucb1x00_drivers, node) {
|
|
|
|
ucb1x00_add_dev(ucb, drv);
|
|
|
|
}
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_unlock(&ucb1x00_mutex);
|
2009-02-10 13:50:56 +00:00
|
|
|
|
2012-01-22 19:02:25 +00:00
|
|
|
return ret;
|
2005-09-11 09:26:31 +00:00
|
|
|
|
|
|
|
err_irq:
|
2009-02-10 13:50:56 +00:00
|
|
|
if (ucb->gpio.base != -1)
|
|
|
|
temp = gpiochip_remove(&ucb->gpio);
|
2012-01-21 14:45:17 +00:00
|
|
|
err_gpio_add:
|
|
|
|
err_no_irq:
|
|
|
|
device_del(&ucb->dev);
|
|
|
|
err_dev_add:
|
|
|
|
put_device(&ucb->dev);
|
2005-09-11 09:26:31 +00:00
|
|
|
out:
|
2012-01-22 19:02:25 +00:00
|
|
|
if (pdata && pdata->reset)
|
|
|
|
pdata->reset(UCB_RST_PROBE_FAIL);
|
2005-09-11 09:26:31 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ucb1x00_remove(struct mcp *mcp)
|
|
|
|
{
|
2012-01-22 19:02:25 +00:00
|
|
|
struct ucb1x00_plat_data *pdata = mcp->attached_device.platform_data;
|
2005-09-11 09:26:31 +00:00
|
|
|
struct ucb1x00 *ucb = mcp_get_drvdata(mcp);
|
|
|
|
struct list_head *l, *n;
|
2009-02-10 13:50:56 +00:00
|
|
|
int ret;
|
2005-09-11 09:26:31 +00:00
|
|
|
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_lock(&ucb1x00_mutex);
|
2005-09-11 09:26:31 +00:00
|
|
|
list_del(&ucb->node);
|
|
|
|
list_for_each_safe(l, n, &ucb->devs) {
|
|
|
|
struct ucb1x00_dev *dev = list_entry(l, struct ucb1x00_dev, dev_node);
|
|
|
|
ucb1x00_remove_dev(dev);
|
|
|
|
}
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_unlock(&ucb1x00_mutex);
|
2005-09-11 09:26:31 +00:00
|
|
|
|
2009-02-10 13:50:56 +00:00
|
|
|
if (ucb->gpio.base != -1) {
|
|
|
|
ret = gpiochip_remove(&ucb->gpio);
|
|
|
|
if (ret)
|
|
|
|
dev_err(&ucb->dev, "Can't remove gpio chip: %d\n", ret);
|
|
|
|
}
|
|
|
|
|
2005-09-11 09:26:31 +00:00
|
|
|
free_irq(ucb->irq, ucb);
|
2007-09-25 00:03:03 +00:00
|
|
|
device_unregister(&ucb->dev);
|
2012-01-22 19:02:25 +00:00
|
|
|
|
|
|
|
if (pdata && pdata->reset)
|
|
|
|
pdata->reset(UCB_RST_REMOVE);
|
2005-09-11 09:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ucb1x00_register_driver(struct ucb1x00_driver *drv)
|
|
|
|
{
|
|
|
|
struct ucb1x00 *ucb;
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&drv->devs);
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_lock(&ucb1x00_mutex);
|
2012-01-21 15:35:01 +00:00
|
|
|
list_add_tail(&drv->node, &ucb1x00_drivers);
|
2005-09-11 09:26:31 +00:00
|
|
|
list_for_each_entry(ucb, &ucb1x00_devices, node) {
|
|
|
|
ucb1x00_add_dev(ucb, drv);
|
|
|
|
}
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_unlock(&ucb1x00_mutex);
|
2005-09-11 09:26:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ucb1x00_unregister_driver(struct ucb1x00_driver *drv)
|
|
|
|
{
|
|
|
|
struct list_head *n, *l;
|
|
|
|
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_lock(&ucb1x00_mutex);
|
2005-09-11 09:26:31 +00:00
|
|
|
list_del(&drv->node);
|
|
|
|
list_for_each_safe(l, n, &drv->devs) {
|
|
|
|
struct ucb1x00_dev *dev = list_entry(l, struct ucb1x00_dev, drv_node);
|
|
|
|
ucb1x00_remove_dev(dev);
|
|
|
|
}
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_unlock(&ucb1x00_mutex);
|
2005-09-11 09:26:31 +00:00
|
|
|
}
|
|
|
|
|
2012-01-21 16:36:30 +00:00
|
|
|
static int ucb1x00_suspend(struct device *dev)
|
2005-09-11 09:26:31 +00:00
|
|
|
{
|
2012-01-21 16:36:30 +00:00
|
|
|
struct ucb1x00 *ucb = dev_get_drvdata(dev);
|
|
|
|
struct ucb1x00_dev *udev;
|
2005-09-11 09:26:31 +00:00
|
|
|
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_lock(&ucb1x00_mutex);
|
2012-01-21 16:36:30 +00:00
|
|
|
list_for_each_entry(udev, &ucb->devs, dev_node) {
|
|
|
|
if (udev->drv->suspend)
|
|
|
|
udev->drv->suspend(udev);
|
2005-09-11 09:26:31 +00:00
|
|
|
}
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_unlock(&ucb1x00_mutex);
|
2005-09-11 09:26:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-21 16:36:30 +00:00
|
|
|
static int ucb1x00_resume(struct device *dev)
|
2005-09-11 09:26:31 +00:00
|
|
|
{
|
2012-01-21 16:36:30 +00:00
|
|
|
struct ucb1x00 *ucb = dev_get_drvdata(dev);
|
|
|
|
struct ucb1x00_dev *udev;
|
2005-09-11 09:26:31 +00:00
|
|
|
|
2012-01-21 18:13:20 +00:00
|
|
|
ucb1x00_enable(ucb);
|
2012-01-21 18:15:24 +00:00
|
|
|
ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out);
|
2009-02-10 13:50:56 +00:00
|
|
|
ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir);
|
2012-01-21 18:13:20 +00:00
|
|
|
ucb1x00_disable(ucb);
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_lock(&ucb1x00_mutex);
|
2012-01-21 16:36:30 +00:00
|
|
|
list_for_each_entry(udev, &ucb->devs, dev_node) {
|
|
|
|
if (udev->drv->resume)
|
|
|
|
udev->drv->resume(udev);
|
2005-09-11 09:26:31 +00:00
|
|
|
}
|
2006-01-12 18:43:35 +00:00
|
|
|
mutex_unlock(&ucb1x00_mutex);
|
2005-09-11 09:26:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-21 16:36:30 +00:00
|
|
|
static const struct dev_pm_ops ucb1x00_pm_ops = {
|
|
|
|
SET_SYSTEM_SLEEP_PM_OPS(ucb1x00_suspend, ucb1x00_resume)
|
|
|
|
};
|
|
|
|
|
2005-09-11 09:26:31 +00:00
|
|
|
static struct mcp_driver ucb1x00_driver = {
|
|
|
|
.drv = {
|
|
|
|
.name = "ucb1x00",
|
2012-01-21 16:33:38 +00:00
|
|
|
.owner = THIS_MODULE,
|
2012-01-21 16:36:30 +00:00
|
|
|
.pm = &ucb1x00_pm_ops,
|
2005-09-11 09:26:31 +00:00
|
|
|
},
|
|
|
|
.probe = ucb1x00_probe,
|
|
|
|
.remove = ucb1x00_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init ucb1x00_init(void)
|
|
|
|
{
|
|
|
|
int ret = class_register(&ucb1x00_class);
|
|
|
|
if (ret == 0) {
|
|
|
|
ret = mcp_driver_register(&ucb1x00_driver);
|
|
|
|
if (ret)
|
|
|
|
class_unregister(&ucb1x00_class);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit ucb1x00_exit(void)
|
|
|
|
{
|
|
|
|
mcp_driver_unregister(&ucb1x00_driver);
|
|
|
|
class_unregister(&ucb1x00_class);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(ucb1x00_init);
|
|
|
|
module_exit(ucb1x00_exit);
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(ucb1x00_io_set_dir);
|
|
|
|
EXPORT_SYMBOL(ucb1x00_io_write);
|
|
|
|
EXPORT_SYMBOL(ucb1x00_io_read);
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(ucb1x00_adc_enable);
|
|
|
|
EXPORT_SYMBOL(ucb1x00_adc_read);
|
|
|
|
EXPORT_SYMBOL(ucb1x00_adc_disable);
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(ucb1x00_hook_irq);
|
|
|
|
EXPORT_SYMBOL(ucb1x00_free_irq);
|
|
|
|
EXPORT_SYMBOL(ucb1x00_enable_irq);
|
|
|
|
EXPORT_SYMBOL(ucb1x00_disable_irq);
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(ucb1x00_register_driver);
|
|
|
|
EXPORT_SYMBOL(ucb1x00_unregister_driver);
|
|
|
|
|
2012-01-21 16:33:38 +00:00
|
|
|
MODULE_ALIAS("mcp:ucb1x00");
|
2005-09-11 09:26:31 +00:00
|
|
|
MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
|
|
|
|
MODULE_DESCRIPTION("UCB1x00 core driver");
|
|
|
|
MODULE_LICENSE("GPL");
|