Skip to content

Commit

Permalink
[ARM] 2911/1: ixp2000_reg_{read,write} accessors
Browse files Browse the repository at this point in the history
Patch from Lennert Buytenhek

This patch:
- changes the ixp2000_reg_write accessor to take a 'volatile void *'
  instead of a 'volatile unsigned long *', which then allows passing in
  a u32 * as first argument without being greeted with a warning; and
- adds an ixp2000_reg_read accessor.
We can then use these accessors in ixp2000 code to access on-chip
peripherals, instead of directly dereferencing pointers.  This is for
use by the ixp2000 microengine driver which was recently announced on
netdev.  We can't use readl/writel on the ixp2000 since it is usually
run in big-endian mode, and on big-endian platforms, readl/writel
perform byteswapping.
A future patch will remove the readback from ixp2000_reg_write, since
it's not needed to prevent erratum #66, and add manual readbacks to the
places that need them (writes are not synchronous since we map in device
space using XCB=101 nowadays), such as interrupt disabling and GPIO
manipulation.  See also:
	http://lists.arm.linux.org.uk/pipermail/linux-arm-kernel/2005-February/027084.html
Patch has been ACKed by Jeff Garzik.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Lennert Buytenhek authored and Russell King committed Sep 15, 2005
1 parent fea2efe commit 917afce
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions include/asm-arm/arch-ixp2000/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,24 @@

#include <asm/system.h> /* Pickup local_irq_ functions */

static inline void ixp2000_reg_write(volatile unsigned long *reg, unsigned long val)
static inline void ixp2000_reg_write(volatile void *reg, unsigned long val)
{
volatile unsigned long dummy;
unsigned long dummy;
unsigned long flags;

local_irq_save(flags);
*reg = val;
*((volatile unsigned long *)reg) = val;
barrier();
dummy = *reg;
dummy = *((volatile unsigned long *)reg);
local_irq_restore(flags);
}
#else
#define ixp2000_reg_write(reg, val) (*reg = val)
static inline void ixp2000_reg_write(volatile void *reg, unsigned long val)
{
*((volatile unsigned long *)reg) = val;
}
#endif /* IXDP2400 || IXDP2401 */
#define ixp2000_reg_read(reg) (*((volatile unsigned long *)reg))

/*
* Boards may multiplex different devices on the 2nd channel of
Expand Down

0 comments on commit 917afce

Please sign in to comment.