From atar4qemu at gmail.com Mon Jan 19 14:24:28 2015 From: atar4qemu at gmail.com (Artyom Tarasenko) Date: Mon, 19 Jan 2015 14:24:28 +0100 Subject: [OpenBIOS] [PATCH 2/2] SPARC64: add an eeprom node to the device tree In-Reply-To: <1421672943-15103-3-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1421672943-15103-1-git-send-email-mark.cave-ayland@ilande.co.uk> <1421672943-15103-3-git-send-email-mark.cave-ayland@ilande.co.uk> Message-ID: 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 wrote: > From: Artyom Tarasenko > > Add eeprom node to the device tree to make device visible for > the guest OS. > > Signed-off-by: Artyom Tarasenko > Signed-off-by: Mark Cave-Ayland > --- > 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 -- Regards, Artyom Tarasenko SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu From mark.cave-ayland at ilande.co.uk Mon Jan 19 14:09:03 2015 From: mark.cave-ayland at ilande.co.uk (Mark Cave-Ayland) Date: Mon, 19 Jan 2015 13:09:03 +0000 Subject: [OpenBIOS] [PATCH 2/2] SPARC64: add an eeprom node to the device tree In-Reply-To: <1421672943-15103-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1421672943-15103-1-git-send-email-mark.cave-ayland@ilande.co.uk> Message-ID: <1421672943-15103-3-git-send-email-mark.cave-ayland@ilande.co.uk> From: Artyom Tarasenko Add eeprom node to the device tree to make device visible for the guest OS. Signed-off-by: Artyom Tarasenko Signed-off-by: Mark Cave-Ayland --- 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 -- 1.7.10.4 From mark.cave-ayland at ilande.co.uk Mon Jan 19 14:09:02 2015 From: mark.cave-ayland at ilande.co.uk (Mark Cave-Ayland) Date: Mon, 19 Jan 2015 13:09:02 +0000 Subject: [OpenBIOS] [PATCH 1/2] SPARC64: use MMIO for NVRAM access In-Reply-To: <1421672943-15103-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1421672943-15103-1-git-send-email-mark.cave-ayland@ilande.co.uk> Message-ID: <1421672943-15103-2-git-send-email-mark.cave-ayland@ilande.co.uk> From: Artyom Tarasenko Use MMIO for accessing the m48t59 NVRAM chip. This patch is a counterpart of a QEMU change. Signed-off-by: Artyom Tarasenko Signed-off-by: Mark Cave-Ayland --- 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]; -- 1.7.10.4 From mark.cave-ayland at ilande.co.uk Mon Jan 19 14:09:01 2015 From: mark.cave-ayland at ilande.co.uk (Mark Cave-Ayland) Date: Mon, 19 Jan 2015 13:09:01 +0000 Subject: [OpenBIOS] [PATCH 0/2] SPARC64: switch to MMIO NVRAM access Message-ID: <1421672943-15103-1-git-send-email-mark.cave-ayland@ilande.co.uk> 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 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(-) -- 1.7.10.4 From mark.cave-ayland at ilande.co.uk Mon Jan 19 17:34:22 2015 From: mark.cave-ayland at ilande.co.uk (Mark Cave-Ayland) Date: Mon, 19 Jan 2015 16:34:22 +0000 Subject: [OpenBIOS] [PATCH 2/2] SPARC64: add an eeprom node to the device tree In-Reply-To: References: <1421672943-15103-1-git-send-email-mark.cave-ayland@ilande.co.uk> <1421672943-15103-3-git-send-email-mark.cave-ayland@ilande.co.uk> Message-ID: <54BD320E.7040806@ilande.co.uk> On 19/01/15 13:24, Artyom Tarasenko wrote: > Hi Mark, > > back then I was in a hurry to get it in an upcoming release. Now as we > are not in a rush... Ha! ;) > On Mon, Jan 19, 2015 at 2:09 PM, Mark Cave-Ayland > wrote: >> From: Artyom Tarasenko >> >> Add eeprom node to the device tree to make device visible for >> the guest OS. >> >> Signed-off-by: Artyom Tarasenko >> Signed-off-by: Mark Cave-Ayland >> --- >> 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 Looks fairly sensible. I'll make the changes and respin in a bit... ATB, Mark.