Happy New Year everyone!
This patchset is a minor rework of Artyom's patchset last year which when combined with the corresponding QEMU patches fixes NVRAM/RTC access under sun4u.
The modifications I've made to the orignal patches are:
1) Change NVRAM_BASE from 0x1000 to 0x2000
NetBSD has a bug where it incorrectly calculates the size of the VA mapping if the NVRAM straddles a page. Fix this by setting the offset to 0x2000 instead of 0x1000 to ensure the NVRAM mapping is aligned to an 8K page.
2) Fixup the eeprom node properties
With the introduction of the new PCI interrupt map, the format of the ebus reg property has changed. Hence I've altered the second patch in the series to bring it in line with the existing ebus devices.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Artyom Tarasenko (2): SPARC64: use MMIO for NVRAM access SPARC64: add an eeprom node to the device tree
openbios-devel/arch/sparc64/openbios.c | 30 ++++++++---------------------- openbios-devel/drivers/pci.c | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 22 deletions(-)
From: Artyom Tarasenko atar4qemu@gmail.com
Use MMIO for accessing the m48t59 NVRAM chip. This patch is a counterpart of a QEMU change.
Signed-off-by: Artyom Tarasenko atar4qemu@gmail.com Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc64/openbios.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-)
diff --git a/openbios-devel/arch/sparc64/openbios.c b/openbios-devel/arch/sparc64/openbios.c index 3a36146..f07c0f3 100644 --- a/openbios-devel/arch/sparc64/openbios.c +++ b/openbios-devel/arch/sparc64/openbios.c @@ -27,9 +27,7 @@
#define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
-#define NVRAM_ADDR_LO 0x74 -#define NVRAM_ADDR_HI 0x75 -#define NVRAM_DATA 0x77 +#define NVRAM_BASE 0x2000
#define APB_SPECIAL_BASE 0x1fe00000000ULL #define APB_MEM_BASE 0x1ff00000000ULL @@ -41,7 +39,7 @@ #define NVRAM_IDPROM 0x1fd8 #define NVRAM_IDPROM_SIZE 32 #define NVRAM_OB_START (0) -#define NVRAM_OB_SIZE ((0x1fd0 - NVRAM_OB_START) & ~15) +#define NVRAM_OB_SIZE ((NVRAM_IDPROM - NVRAM_OB_START) & ~15)
static uint8_t idprom[NVRAM_IDPROM_SIZE];
@@ -352,34 +350,22 @@ id_cpu(void) for (;;); }
-static uint8_t nvram_read_byte(uint16_t offset) -{ - outb(offset & 0xff, NVRAM_ADDR_LO); - outb(offset >> 8, NVRAM_ADDR_HI); - return inb(NVRAM_DATA); -} - static void nvram_read(uint16_t offset, char *buf, unsigned int nbytes) { unsigned int i;
- for (i = 0; i < nbytes; i++) - buf[i] = nvram_read_byte(offset + i); -} - -static void nvram_write_byte(uint16_t offset, uint8_t val) -{ - outb(offset & 0xff, NVRAM_ADDR_LO); - outb(offset >> 8, NVRAM_ADDR_HI); - outb(val, NVRAM_DATA); + for (i = 0; i < nbytes; i++) { + buf[i] = inb(NVRAM_BASE + offset + i); + } }
static void nvram_write(uint16_t offset, const char *buf, unsigned int nbytes) { unsigned int i;
- for (i = 0; i < nbytes; i++) - nvram_write_byte(offset + i, buf[i]); + for (i = 0; i < nbytes; i++) { + outb(buf[i], NVRAM_BASE + offset + i); + } }
static uint8_t qemu_uuid[16];
From: Artyom Tarasenko atar4qemu@gmail.com
Add eeprom node to the device tree to make device visible for the guest OS.
Signed-off-by: Artyom Tarasenko atar4qemu@gmail.com Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/drivers/pci.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c index 3260354..366f4a1 100644 --- a/openbios-devel/drivers/pci.c +++ b/openbios-devel/drivers/pci.c @@ -831,6 +831,26 @@ int ebus_config_cb(const pci_config_t *config)
set_property(dev, "ranges", (char *)props, ncells * sizeof(props[0]));
+ /* Build eeprom node */ + fword("new-device"); + PUSH(0x14); + fword("encode-int"); + PUSH(0x2000); + fword("encode-int"); + fword("encode+"); + PUSH(0x2000); + fword("encode-int"); + fword("encode+"); + push_str("reg"); + fword("property"); + + push_str("mk48t59"); + fword("model"); + + push_str("eeprom"); + fword("device-name"); + fword("finish-device"); + #ifdef CONFIG_DRIVER_FLOPPY ob_floppy_init(config->path, "fdthree", 0x3f0ULL, 0); #endif
Hi Mark,
back then I was in a hurry to get it in an upcoming release. Now as we are not in a rush...
On Mon, Jan 19, 2015 at 2:09 PM, Mark Cave-Ayland mark.cave-ayland@ilande.co.uk wrote:
From: Artyom Tarasenko atar4qemu@gmail.com
Add eeprom node to the device tree to make device visible for the guest OS.
Signed-off-by: Artyom Tarasenko atar4qemu@gmail.com Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
openbios-devel/drivers/pci.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c index 3260354..366f4a1 100644 --- a/openbios-devel/drivers/pci.c +++ b/openbios-devel/drivers/pci.c @@ -831,6 +831,26 @@ int ebus_config_cb(const pci_config_t *config)
set_property(dev, "ranges", (char *)props, ncells * sizeof(props[0]));
- /* Build eeprom node */
- fword("new-device");
- PUSH(0x14);
- fword("encode-int");
- PUSH(0x2000);
PUSH(NVRAM_BASE)
- fword("encode-int");
- fword("encode+");
- PUSH(0x2000);
PUSH(NVRAM_SIZE);
- fword("encode-int");
- fword("encode+");
- push_str("reg");
- fword("property");
- push_str("mk48t59");
- fword("model");
- push_str("eeprom");
- fword("device-name");
- fword("finish-device");
#ifdef CONFIG_DRIVER_FLOPPY ob_floppy_init(config->path, "fdthree", 0x3f0ULL, 0);
#endif
1.7.10.4
Artyom