summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-07-12 07:25:01 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-07-12 07:25:01 +0000
commit192a604cd4bee82d52826b7cab8f91bfc1d35ef4 (patch)
tree6854e57eb3f03836a57f060cd3fa90657270317a /firmware
parentd2ca7fc5de5e9a6aea09f4b97351bccd08a9bb38 (diff)
downloadrockbox-192a604cd4bee82d52826b7cab8f91bfc1d35ef4.tar.gz
rockbox-192a604cd4bee82d52826b7cab8f91bfc1d35ef4.zip
Atomic GPIO access
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7114 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/adc.c23
-rw-r--r--firmware/drivers/ata.c24
-rw-r--r--firmware/drivers/power.c26
-rw-r--r--firmware/usb.c12
4 files changed, 43 insertions, 42 deletions
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c
index 69aeb2996e..1292548e88 100644
--- a/firmware/drivers/adc.c
+++ b/firmware/drivers/adc.c
@@ -18,6 +18,7 @@
****************************************************************************/
#include "config.h"
#include "cpu.h"
+#include "system.h"
#include "kernel.h"
#include "thread.h"
#include "adc.h"
@@ -111,11 +112,11 @@ static unsigned char adcdata[NUM_ADC_CHANNELS];
#define CS_LO GPIO_OUT &= ~0x80
#define CS_HI GPIO_OUT |= 0x80
-#define CLK_LO GPIO_OUT &= ~0x00400000
-#define CLK_HI GPIO_OUT |= 0x00400000
+#define CLK_LO and_l(~0x00400000, &GPIO_OUT)
+#define CLK_HI or_l(0x00400000, &GPIO_OUT)
#define DO (GPIO_READ & 0x80000000)
-#define DI_LO GPIO_OUT &= ~0x00200000
-#define DI_HI GPIO_OUT |= 0x00200000
+#define DI_LO and_l(~0x00200000, &GPIO_OUT)
+#define DI_HI or_l(0x00200000, &GPIO_OUT)
/* delay loop */
#define DELAY do { int _x; for(_x=0;_x<10;_x++);} while (0)
@@ -194,13 +195,13 @@ static void adc_tick(void)
void adc_init(void)
{
- GPIO_FUNCTION |= 0x80600080; /* GPIO7: CS
- GPIO21: Data In (to the ADC)
- GPIO22: CLK
- GPIO31: Data Out (from the ADC) */
- GPIO_ENABLE |= 0x00600080;
- GPIO_OUT |= 0x80; /* CS high */
- GPIO_OUT &= ~0x00400000; /* CLK low */
+ or_l(0x80600080, &GPIO_FUNCTION); /* GPIO7: CS
+ GPIO21: Data In (to the ADC)
+ GPIO22: CLK
+ GPIO31: Data Out (from the ADC) */
+ or_l(0x00600080, &GPIO_ENABLE);
+ or_l(0x80, &GPIO_OUT); /* CS high */
+ and_l(~0x00400000, &GPIO_OUT); /* CLK low */
adc_scan(ADC_BATTERY);
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 9bf1815e36..61365094bc 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -1092,10 +1092,10 @@ int ata_hard_reset(void)
or_b(0x02, &PADRH); /* negate _RESET */
sleep(1); /* > 2ms */
#elif CONFIG_CPU == MCF5249
- GPIO_OUT &= ~0x00080000;
+ and_l(~0x00080000, &GPIO_OUT);
sleep(1); /* > 25us */
- GPIO_OUT |= 0x00080000;
+ or_l(0x00080000, &GPIO_OUT);
sleep(1); /* > 25us */
#elif CONFIG_CPU == TCC730
@@ -1234,12 +1234,12 @@ void ata_enable(bool on)
or_b(0x80, &PAIORL);
#elif CONFIG_CPU == MCF5249
if(on)
- GPIO_OUT &= ~0x0040000;
+ and_l(~0x0040000, &GPIO_OUT);
else
- GPIO_OUT |= 0x0040000;
+ or_l(0x0040000, &GPIO_OUT);
- GPIO_ENABLE |= 0x00040000;
- GPIO_FUNCTION |= 0x00040000;
+ or_l(0x00040000, &GPIO_ENABLE);
+ or_l(0x00040000, &GPIO_FUNCTION);
#elif CONFIG_CPU == TCC730
#endif
@@ -1408,14 +1408,14 @@ int ata_init(void)
PACR2 &= 0xBFFF; /* GPIO function for PA7 (IDE enable) */
#elif CONFIG_CPU == MCF5249
/* Enable disk LED & ISD chip power control */
- GPIO_OUT &= ~0x0000240;
- GPIO_ENABLE |= 0x00000240;
- GPIO_FUNCTION |= 0x00000200;
+ and_l(~0x0000240, &GPIO_OUT);
+ or_l(0x00000240, &GPIO_ENABLE);
+ or_l(0x00000200, &GPIO_FUNCTION);
/* ATA reset */
- GPIO_OUT |= 0x00080000;
- GPIO_ENABLE |= 0x00080000;
- GPIO_FUNCTION |= 0x00080000;
+ or_l(0x00080000, &GPIO_OUT);
+ or_l(0x00080000, &GPIO_ENABLE);
+ or_l(0x00080000, &GPIO_FUNCTION);
/* FYI: The IDECONFIGx registers are set by set_cpu_frequency() */
#endif
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index ce1a9ff377..b87aa79e0a 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -60,16 +60,16 @@ int radio_get_status(void)
void power_init(void)
{
#if CONFIG_CPU == MCF5249
- GPIO1_OUT |= 0x00080000;
- GPIO1_ENABLE |= 0x00080000;
- GPIO1_FUNCTION |= 0x00080000;
+ or_l(0x00080000, &GPIO1_OUT);
+ or_l(0x00080000, &GPIO1_ENABLE);
+ or_l(0x00080000, &GPIO1_FUNCTION);
#ifdef BOOTLOADER
/* Hard drive power default = off in bootloader*/
- GPIO_OUT |= 0x80000000;
+ or_l(0x80000000, &GPIO_OUT);
#endif
- GPIO_ENABLE |= 0x80000000;
- GPIO_FUNCTION |= 0x80000000;
+ or_l(0x80000000, &GPIO_ENABLE);
+ or_l(0x80000000, &GPIO_FUNCTION);
#ifdef HAVE_SPDIF_POWER
spdif_power_enable(false);
#endif
@@ -139,17 +139,17 @@ void charger_enable(bool on)
#ifdef HAVE_SPDIF_POWER
void spdif_power_enable(bool on)
{
- GPIO1_FUNCTION |= 0x01000000;
- GPIO1_ENABLE |= 0x01000000;
+ or_l(0x01000000, &GPIO1_FUNCTION);
+ or_l(0x01000000, &GPIO1_ENABLE);
#ifdef SPDIF_POWER_INVERTED
if(!on)
#else
if(on)
#endif
- GPIO1_OUT &= ~0x01000000;
+ and_l(~0x01000000, &GPIO1_OUT);
else
- GPIO1_OUT |= 0x01000000;
+ or_l(0x01000000, &GPIO1_OUT);
}
#endif
@@ -160,9 +160,9 @@ void ide_power_enable(bool on)
#if CONFIG_CPU == MCF5249
if(on)
- GPIO_OUT &= ~0x80000000;
+ and_l(~0x80000000, &GPIO_OUT);
else
- GPIO_OUT |= 0x80000000;
+ or_l(0x80000000, &GPIO_OUT);
#elif defined(GMINI_ARCH)
if(on)
P1 |= 0x08;
@@ -243,7 +243,7 @@ void power_off(void)
{
set_irq_level(HIGHEST_IRQ_LEVEL);
#if CONFIG_CPU == MCF5249
- GPIO1_OUT &= ~0x00080000;
+ and_l(~0x00080000, &GPIO1_OUT);
#elif defined(GMINI_ARCH)
P1 &= ~1;
P1CON &= ~1;
diff --git a/firmware/usb.c b/firmware/usb.c
index e217bf4680..6fc96a1811 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -134,13 +134,13 @@ static void usb_enable(bool on)
if(on)
{
/* Power on the Cypress chip */
- GPIO_OUT |= 0x01000000;
+ or_l(0x01000000, &GPIO_OUT);
sleep(2);
}
else
{
/* Power off the Cypress chip */
- GPIO_OUT &= ~0x01000000;
+ and_l(~0x01000000, &GPIO_OUT);
}
#else
@@ -429,11 +429,11 @@ void usb_init(void)
countdown = -1;
#ifdef USB_IRIVERSTYLE
- GPIO_OUT &= ~0x01000000; /* GPIO24 is the Cypress chip power */
- GPIO_ENABLE |= 0x01000000;
- GPIO_FUNCTION |= 0x01000000;
+ and_l(~0x01000000, &GPIO_OUT); /* GPIO24 is the Cypress chip power */
+ or_l(0x01000000, &GPIO_ENABLE);
+ or_l(0x01000000, &GPIO_FUNCTION);
- GPIO1_FUNCTION |= 0x00000080; /* GPIO39 is the USB detect input */
+ or_l(0x00000080, &GPIO1_FUNCTION); /* GPIO39 is the USB detect input */
#endif
usb_enable(false);