diff options
Diffstat (limited to 'kernel/Documentation/blackfin')
-rw-r--r-- | kernel/Documentation/blackfin/00-INDEX | 10 | ||||
-rw-r--r-- | kernel/Documentation/blackfin/Makefile | 5 | ||||
-rw-r--r-- | kernel/Documentation/blackfin/bfin-gpio-notes.txt | 71 | ||||
-rw-r--r-- | kernel/Documentation/blackfin/bfin-spi-notes.txt | 16 | ||||
-rw-r--r-- | kernel/Documentation/blackfin/gptimers-example.c | 83 |
5 files changed, 185 insertions, 0 deletions
diff --git a/kernel/Documentation/blackfin/00-INDEX b/kernel/Documentation/blackfin/00-INDEX new file mode 100644 index 000000000..c54fcdd4a --- /dev/null +++ b/kernel/Documentation/blackfin/00-INDEX @@ -0,0 +1,10 @@ +00-INDEX + - This file +Makefile + - Makefile for gptimers example file. +bfin-gpio-notes.txt + - Notes in developing/using bfin-gpio driver. +bfin-spi-notes.txt + - Notes for using bfin spi bus driver. +gptimers-example.c + - gptimers example diff --git a/kernel/Documentation/blackfin/Makefile b/kernel/Documentation/blackfin/Makefile new file mode 100644 index 000000000..6782c58fb --- /dev/null +++ b/kernel/Documentation/blackfin/Makefile @@ -0,0 +1,5 @@ +ifneq ($(CONFIG_BLACKFIN),) +ifneq ($(CONFIG_BFIN_GPTIMERS),) +obj-m := gptimers-example.o +endif +endif diff --git a/kernel/Documentation/blackfin/bfin-gpio-notes.txt b/kernel/Documentation/blackfin/bfin-gpio-notes.txt new file mode 100644 index 000000000..d245f39c3 --- /dev/null +++ b/kernel/Documentation/blackfin/bfin-gpio-notes.txt @@ -0,0 +1,71 @@ +/* + * File: Documentation/blackfin/bfin-gpio-notes.txt + * Based on: + * Author: + * + * Created: $Id: bfin-gpio-note.txt 2008-11-24 16:42 grafyang $ + * Description: This file contains the notes in developing/using bfin-gpio. + * + * + * Rev: + * + * Modified: + * Copyright 2004-2008 Analog Devices Inc. + * + * Bugs: Enter bugs at http://blackfin.uclinux.org/ + * + */ + + +1. Blackfin GPIO introduction + + There are many GPIO pins on Blackfin. Most of these pins are muxed to + multi-functions. They can be configured as peripheral, or just as GPIO, + configured to input with interrupt enabled, or output. + + For detailed information, please see "arch/blackfin/kernel/bfin_gpio.c", + or the relevant HRM. + + +2. Avoiding resource conflict + + Followed function groups are used to avoiding resource conflict, + - Use the pin as peripheral, + int peripheral_request(unsigned short per, const char *label); + int peripheral_request_list(const unsigned short per[], const char *label); + void peripheral_free(unsigned short per); + void peripheral_free_list(const unsigned short per[]); + - Use the pin as GPIO, + int bfin_gpio_request(unsigned gpio, const char *label); + void bfin_gpio_free(unsigned gpio); + - Use the pin as GPIO interrupt, + int bfin_gpio_irq_request(unsigned gpio, const char *label); + void bfin_gpio_irq_free(unsigned gpio); + + The request functions will record the function state for a certain pin, + the free functions will clear its function state. + Once a pin is requested, it can't be requested again before it is freed by + previous caller, otherwise kernel will dump stacks, and the request + function fail. + These functions are wrapped by other functions, most of the users need not + care. + + +3. But there are some exceptions + - Kernel permit the identical GPIO be requested both as GPIO and GPIO + interrupt. + Some drivers, like gpio-keys, need this behavior. Kernel only print out + warning messages like, + bfin-gpio: GPIO 24 is already reserved by gpio-keys: BTN0, and you are +configuring it as IRQ! + + Note: Consider the case that, if there are two drivers need the + identical GPIO, one of them use it as GPIO, the other use it as + GPIO interrupt. This will really cause resource conflict. So if + there is any abnormal driver behavior, please check the bfin-gpio + warning messages. + + - Kernel permit the identical GPIO be requested from the same driver twice. + + + diff --git a/kernel/Documentation/blackfin/bfin-spi-notes.txt b/kernel/Documentation/blackfin/bfin-spi-notes.txt new file mode 100644 index 000000000..eae6eaf2a --- /dev/null +++ b/kernel/Documentation/blackfin/bfin-spi-notes.txt @@ -0,0 +1,16 @@ +SPI Chip Select behavior: + +With the Blackfin on-chip SPI peripheral, there is some logic tied to the CPHA +bit whether the Slave Select Line is controlled by hardware (CPHA=0) or +controlled by software (CPHA=1). However, the Linux SPI bus driver assumes that +the Slave Select is always under software control and being asserted during +the entire SPI transfer. - And not just bits_per_word duration. + +In most cases you can utilize SPI MODE_3 instead of MODE_0 to work-around this +behavior. If your SPI slave device in question requires SPI MODE_0 or MODE_2 +timing, you can utilize the GPIO controlled SPI Slave Select option instead. +In this case, you should use GPIO based CS for all of your slaves and not just +the ones using mode 0 or 2 in order to guarantee correct CS toggling behavior. + +You can even use the same pin whose peripheral role is a SSEL, +but use it as a GPIO instead. diff --git a/kernel/Documentation/blackfin/gptimers-example.c b/kernel/Documentation/blackfin/gptimers-example.c new file mode 100644 index 000000000..b1bd6340e --- /dev/null +++ b/kernel/Documentation/blackfin/gptimers-example.c @@ -0,0 +1,83 @@ +/* + * Simple gptimers example + * http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gptimers + * + * Copyright 2007-2009 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#include <linux/interrupt.h> +#include <linux/module.h> + +#include <asm/gptimers.h> +#include <asm/portmux.h> + +/* ... random driver includes ... */ + +#define DRIVER_NAME "gptimer_example" + +struct gptimer_data { + uint32_t period, width; +}; +static struct gptimer_data data; + +/* ... random driver state ... */ + +static irqreturn_t gptimer_example_irq(int irq, void *dev_id) +{ + struct gptimer_data *data = dev_id; + + /* make sure it was our timer which caused the interrupt */ + if (!get_gptimer_intr(TIMER5_id)) + return IRQ_NONE; + + /* read the width/period values that were captured for the waveform */ + data->width = get_gptimer_pwidth(TIMER5_id); + data->period = get_gptimer_period(TIMER5_id); + + /* acknowledge the interrupt */ + clear_gptimer_intr(TIMER5_id); + + /* tell the upper layers we took care of things */ + return IRQ_HANDLED; +} + +/* ... random driver code ... */ + +static int __init gptimer_example_init(void) +{ + int ret; + + /* grab the peripheral pins */ + ret = peripheral_request(P_TMR5, DRIVER_NAME); + if (ret) { + printk(KERN_NOTICE DRIVER_NAME ": peripheral request failed\n"); + return ret; + } + + /* grab the IRQ for the timer */ + ret = request_irq(IRQ_TIMER5, gptimer_example_irq, IRQF_SHARED, DRIVER_NAME, &data); + if (ret) { + printk(KERN_NOTICE DRIVER_NAME ": IRQ request failed\n"); + peripheral_free(P_TMR5); + return ret; + } + + /* setup the timer and enable it */ + set_gptimer_config(TIMER5_id, WDTH_CAP | PULSE_HI | PERIOD_CNT | IRQ_ENA); + enable_gptimers(TIMER5bit); + + return 0; +} +module_init(gptimer_example_init); + +static void __exit gptimer_example_exit(void) +{ + disable_gptimers(TIMER5bit); + free_irq(IRQ_TIMER5, &data); + peripheral_free(P_TMR5); +} +module_exit(gptimer_example_exit); + +MODULE_LICENSE("BSD"); |