[U-Boot-Users] pci_hose_write_config_{byte,word}_via_dword?

Masao Uebayashi uebayasi at pultek.co.jp
Sun Apr 11 06:44:52 CEST 2004


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

#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;							\
}




More information about the U-Boot mailing list