From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 22/29] cpu/mpc512x/i2c.c: use immr offsets from C struct instead of #define
Date: Sun, 10 May 2009 10:37:07 +0200 [thread overview]
Message-ID: <4A069233.2080101@denx.de> (raw)
In-Reply-To: <1241898668-11903-23-git-send-email-wd@denx.de>
Hello Wolfgang,
Wolfgang Denk wrote:
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> Cc: John Rigby <jcrigby@gmail.com>
> ---
> cpu/mpc512x/i2c.c | 33 ++++++++++++++++++++-------------
> 1 files changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/cpu/mpc512x/i2c.c b/cpu/mpc512x/i2c.c
> index 812f24a..e9bb3e7 100644
> --- a/cpu/mpc512x/i2c.c
> +++ b/cpu/mpc512x/i2c.c
> @@ -31,8 +31,6 @@ DECLARE_GLOBAL_DATA_PTR;
>
> #include <i2c.h>
>
> -#define immr ((immap_t *)CONFIG_SYS_IMMR)
> -
> /* by default set I2C bus 0 active */
> static unsigned int bus_num = 0;
If no other bus then the first needed, when running from Flash,
its okay for me.
> @@ -77,7 +75,8 @@ static void mpc_reg_out (volatile u32 *reg, int val, int mask)
>
> static int wait_for_bb (void)
> {
> - i2c512x_dev_t *regs = &immr->i2c.dev[bus_num];
> + volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
> + volatile i2c512x_dev_t *regs = &im->i2c.dev[bus_num];
> int timeout = I2C_TIMEOUT;
> int status;
>
> @@ -100,7 +99,8 @@ static int wait_for_bb (void)
>
> static int wait_for_pin (int *status)
> {
> - i2c512x_dev_t *regs = &immr->i2c.dev[bus_num];
> + volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
> + volatile i2c512x_dev_t *regs = &im->i2c.dev[bus_num];
> int timeout = I2C_TIMEOUT;
>
> *status = mpc_reg_in (®s->msr);
> @@ -121,7 +121,8 @@ static int wait_for_pin (int *status)
>
> static int do_address (uchar chip, char rdwr_flag)
> {
> - i2c512x_dev_t *regs = &immr->i2c.dev[bus_num];
> + volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
> + volatile i2c512x_dev_t *regs = &im->i2c.dev[bus_num];
> int status;
>
> chip <<= 1;
> @@ -146,7 +147,8 @@ static int do_address (uchar chip, char rdwr_flag)
>
> static int send_bytes (uchar chip, char *buf, int len)
> {
> - i2c512x_dev_t *regs = &immr->i2c.dev[bus_num];
> + volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
> + volatile i2c512x_dev_t *regs = &im->i2c.dev[bus_num];
> int wrcount;
> int status;
>
> @@ -169,7 +171,8 @@ static int send_bytes (uchar chip, char *buf, int len)
>
> static int receive_bytes (uchar chip, char *buf, int len)
> {
> - i2c512x_dev_t *regs = &immr->i2c.dev[bus_num];
> + volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
> + volatile i2c512x_dev_t *regs = &im->i2c.dev[bus_num];
> int dummy = 1;
> int rdcount = 0;
> int status;
> @@ -207,9 +210,10 @@ static int receive_bytes (uchar chip, char *buf, int len)
>
> void i2c_init (int speed, int saddr)
> {
> + volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
> int i;
> for(i = 0; i < I2C_BUS_CNT; i++){
> - i2c512x_dev_t *regs = &immr->i2c.dev[i];
> + volatile i2c512x_dev_t *regs = &im->i2c.dev[i];
> mpc_reg_out (®s->mcr, 0, 0);
>
> /* Set clock */
> @@ -222,9 +226,9 @@ void i2c_init (int speed, int saddr)
> }
>
> /* Disable interrupts */
> - immr->i2c.icr = 0;
> + im->i2c.icr = 0;
shouldn;t we use in/out accessors for this?
> /* Turn off filters */
> - immr->i2c.mifr = 0;
> + im->i2c.mifr = 0;
here too (and so on) ...
> return;
> }
>
> @@ -280,7 +284,8 @@ static int mpc_get_fdr (int speed)
>
> int i2c_probe (uchar chip)
> {
> - i2c512x_dev_t *regs = &immr->i2c.dev[bus_num];
> + volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
> + volatile i2c512x_dev_t *regs = &im->i2c.dev[bus_num];
> int i;
>
> for (i = 0; i < I2C_RETRIES; i++) {
> @@ -301,8 +306,9 @@ int i2c_probe (uchar chip)
>
> int i2c_read (uchar chip, uint addr, int alen, uchar *buf, int len)
> {
> + volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
> + volatile i2c512x_dev_t *regs = &im->i2c.dev[bus_num];
> char xaddr[4];
> - i2c512x_dev_t *regs = &immr->i2c.dev[bus_num];
> int ret = -1;
>
> xaddr[0] = (addr >> 24) & 0xFF;
> @@ -345,8 +351,9 @@ Done:
>
> int i2c_write (uchar chip, uint addr, int alen, uchar *buf, int len)
> {
> + volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
> + volatile i2c512x_dev_t *regs = &im->i2c.dev[bus_num];
> char xaddr[4];
> - i2c512x_dev_t *regs = &immr->i2c.dev[bus_num];
> int ret = -1;
>
> xaddr[0] = (addr >> 24) & 0xFF;
bye
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2009-05-10 8:37 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-09 19:50 [U-Boot] [PATCH 00/29] Rework MPC512x Support Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 01/29] mpc512x: change cpu/mpc512x/Makefile to use Kconfig style Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 02/29] mpc512x: Move common files to share them by several boards Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 03/29] cpu/mpc512x/pci.c: minor coding style cleanup Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 04/29] cpu/mpc512x/diu.c: fix warning: assignment from incompatible pointer type Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 05/29] Rename ads5121 board into mpc5121ads Wolfgang Denk
2009-05-12 20:01 ` Kim Phillips
2009-05-12 21:16 ` Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 06/29] MPC512x: add more hardware description to immap_512x.h Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 07/29] mpc5121ads: use I/O accessors instead of pointer accesses Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 08/29] MPC512x: add support for ARIA board Wolfgang Denk
2009-05-10 8:36 ` Heiko Schocher
2009-05-10 18:55 ` Wolfgang Denk
2009-05-11 7:17 ` Stefan Roese
2009-05-11 7:38 ` Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 09/29] cpu/mpc512x/iopin.c: convert to use I/O acessors Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 10/29] cpu/mpc512x/iopin.c: remove redundant include of <asm/immap_512x.h> Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 11/29] MPC512x: prepare removal of include/mpc512x.h Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 12/29] include/configs/mpc5121ads.h: " Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 13/29] include/configs/aria.h: " Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 14/29] common/cmd_ide.c: " Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 15/29] cpu/mpc512x/cpu.c: " Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 16/29] cpu/mpc512x/cpu_init.c: " Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 17/29] cpu/mpc512x/cpu_init.c: use I/O accessors instead of pointer accesses Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 18/29] cpu/mpc512x/speed.c: prepare removal of include/mpc512x.h Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 19/29] cpu/mpc512x/speed.c: use I/O accessors instead of pointer accesses Wolfgang Denk
2009-05-09 19:50 ` [U-Boot] [PATCH 20/29] cpu/mpc512x/serial.c: " Wolfgang Denk
2009-05-09 19:51 ` [U-Boot] [PATCH 21/29] cpu/mpc512x/i2c.c: prepare removal of include/mpc512x.h Wolfgang Denk
2009-05-10 8:36 ` Heiko Schocher
2009-05-09 19:51 ` [U-Boot] [PATCH 22/29] cpu/mpc512x/i2c.c: use immr offsets from C struct instead of #define Wolfgang Denk
2009-05-10 8:37 ` Heiko Schocher [this message]
2009-05-10 12:29 ` Wolfgang Denk
2009-05-10 16:28 ` Heiko Schocher
2009-05-10 17:49 ` Wolfgang Denk
2009-05-09 19:51 ` [U-Boot] [PATCH 23/29] cpu/mpc512x/i2c.c: use I/O accessors instead of pointer accesses Wolfgang Denk
2009-05-10 8:37 ` Heiko Schocher
2009-05-09 19:51 ` [U-Boot] [PATCH 24/29] cpu/mpc512x/pci.c: " Wolfgang Denk
2009-05-09 19:51 ` [U-Boot] [PATCH 25/29] drivers/net/mpc512x_fec.c: prepare removal of include/mpc512x.h Wolfgang Denk
2009-05-09 19:51 ` [U-Boot] [PATCH 26/29] MPC512x FEC: remove duplicated code and data types Wolfgang Denk
2009-05-09 19:51 ` [U-Boot] [PATCH 27/29] drivers/net/mpc512x_fec.c: use I/O accessors instead of pointer accesses Wolfgang Denk
2009-05-09 19:51 ` [U-Boot] [PATCH 28/29] MPC512x FEC: get rid of duplicated struct ethernet_regs Wolfgang Denk
2009-05-09 19:51 ` [U-Boot] [PATCH 29/29] Remove include/mpc512x.h Wolfgang Denk
2009-05-11 22:08 ` [U-Boot] [PATCH 00/29] Rework MPC512x Support John Rigby
2009-05-15 19:56 ` Wolfgang Denk
2009-05-12 20:01 ` Kim Phillips
2009-05-12 21:21 ` Wolfgang Denk
2009-05-12 22:16 ` Kim Phillips
2009-05-15 20:06 ` Wolfgang Denk
2009-05-16 8:47 ` [U-Boot] [PATCH v2 00/10] " Wolfgang Denk
2009-05-16 8:47 ` [U-Boot] [PATCH v2 01/10] mpc512x: change cpu/mpc512x/Makefile to use Kconfig style Wolfgang Denk
2009-05-16 8:47 ` [U-Boot] [PATCH v2 02/10] mpc512x: Move common files to share them by several boards Wolfgang Denk
2009-05-16 8:47 ` [U-Boot] [PATCH v2 03/10] cpu/mpc512x/pci.c: minor coding style cleanup Wolfgang Denk
2009-05-16 8:47 ` [U-Boot] [PATCH v2 04/10] cpu/mpc512x/diu.c: fix warning: assignment from incompatible pointer type Wolfgang Denk
2009-05-16 8:47 ` [U-Boot] [PATCH v2 05/10] Rename ads5121 board into mpc5121ads Wolfgang Denk
2009-05-18 22:46 ` Kim Phillips
2009-05-20 16:44 ` Arno Fischer
2009-05-20 18:47 ` Wolfgang Denk
2009-05-16 8:47 ` [U-Boot] [PATCH v2 06/10] MPC512x: add more hardware description to immap_512x.h Wolfgang Denk
2009-05-16 8:47 ` [U-Boot] [PATCH v2 07/10] MPC512x: use I/O accessors instead of pointer accesses Wolfgang Denk
2009-05-16 8:47 ` [U-Boot] [PATCH v2 08/10] MPC512x FEC: get rid of duplicated struct ethernet_regs Wolfgang Denk
2009-05-26 6:42 ` Ben Warren
2009-05-28 20:16 ` Wolfgang Denk
2009-05-28 21:05 ` Ben Warren
2009-05-28 21:58 ` Wolfgang Denk
2009-05-16 8:47 ` [U-Boot] [PATCH v2 09/10] MPC512x: remove include/mpc512x.h Wolfgang Denk
2009-05-16 8:47 ` [U-Boot] [PATCH v2 10/10] MPC512x: add support for ARIA board Wolfgang Denk
2009-06-02 9:12 ` Stefan Roese
2009-06-05 12:14 ` Wolfgang Denk
2009-05-28 12:04 ` [U-Boot] [PATCH 00/29] Rework MPC512x Support Arno Fischer
2009-05-28 13:09 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A069233.2080101@denx.de \
--to=hs@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox