public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Masami Komiya <mkomiya@sonare.it>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] pci_hose_write_config_{byte,word}_via_dword?
Date: Mon, 12 Apr 2004 16:54:22 +0900	[thread overview]
Message-ID: <407A4B2E.5070606@sonare.it> (raw)
In-Reply-To: 20040411.134452.730550502.uebayasi@pultek.co.jp

I have confirmed the problem reported in this list.

When pci_hose_write_config_{byte,word}_via_dword is used
the upper byte is destroied.

If you can access pci device, please execute pci command
as the followings.

# pci w.l 00.0c.00 10 12345600
# pci display 00.0c.00 10
00000010: 12345601 10000000 00000000 00000000

# pci w.b 00.0c.00 13 ff
# pci display 00.0c.00 10
00000010: ff345601 10000000 00000000 00000000 <== GOOD

-----------------------------------------------------------

# pci w.l 00.0c.00 10 12345600
# pci display 00.0c.00 10
00000010: 12345601 10000000 00000000 00000000

# pci w.b 00.0c.00 12 ff
# pci display 00.0c.00 10
00000010: 00ff5601 10000000 00000000 00000000 <== NG

-----------------------------------------------------------

# pci w.l 00.0c.00 10 12345600
# pci display 00.0c.00 10
00000010: 12345601 10000000 00000000 00000000

# pci w.b 00.0c.00 11 ff
# pci display 00.0c.00 10
00000010: 0034ff01 10000000 00000000 00000000 <== NG

-----------------------------------------------------------

# pci w.l 00.0c.00 10 12345600
# pci display 00.0c.00 10
00000010: 12345601 10000000 00000000 00000000

# pci w.w 00.0c.00 10 ffff
# pci display 00.0c.00 10
00000010: 0000ff01 10000000 00000000 00000000 <== NG

How is your result ?

Best regards.

Masami Komiya


Masao Uebayashi wrote:
> Hello.
> 
> Is there anyone successfully using
> pci_hose_write_config_{byte,word}_via_dword defined as a macro in
> drivers/pci.c?  Or, are you sure what the code there is doing?  When I
> tried to use it, writing a byte failed and I used the following code.
> 
> I think the current code is just wrong, but I can't explain how it's
> wrong since I can't understand the intention of the code. :-)
> 
> Masao
> \f
> #define	__mask(_o, _v)							\
> 	(_v << ((offset & _o) * 8))
> 
> #define	__data(_o, _v)							\
> 	((((unsigned long)(val)) & _v) << ((offset & _o) * 8))
> 
> #define PCI_WRITE_VIA_DWORD_OP(__size, __type, __offsetmask, __valmask)	\
> int pci_hose_write_config_##__size##_via_dword(				\
> 	struct pci_controller *hose,					\
> 	pci_dev_t dev,							\
> 	int offset,							\
> 	__type val)							\
> {									\
> 	u32 val32;							\
> 									\
> 	if (pci_hose_read_config_dword(hose, dev, offset & ~0x3, &val32) < 0) \
> 		return -1;						\
> 	/* Clear a byte/word in a word. */				\
> 	val32 &= ~__mask(__offsetmask, __valmask);			\
> 	/* Fill a cleared byte/word in a word with a byte/word value. */ \
> 	val32 |= __data(__offsetmask, __valmask);			\
> 	/* Write the value as a word! */				\
> 	if (pci_hose_write_config_dword(hose, dev, offset & ~0x3, val32) < 0) \
> 		return -1;						\
> 									\
> 	return 0;							\
> }
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> U-Boot-Users mailing list
> U-Boot-Users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/u-boot-users
> 
> 

  reply	other threads:[~2004-04-12  7:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-09 11:51 [U-Boot-Users] TFTP boot in u-boot Kruthi
2004-04-09 11:28 ` ganapathi
2004-04-09 14:01   ` Wolfgang Denk
2004-04-11  4:44     ` [U-Boot-Users] pci_hose_write_config_{byte,word}_via_dword? Masao Uebayashi
2004-04-12  7:54       ` Masami Komiya [this message]
2004-04-12  9:10         ` Masami Komiya
2004-04-18 22:07           ` 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=407A4B2E.5070606@sonare.it \
    --to=mkomiya@sonare.it \
    --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