mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-29 07:53:44 +02:00
it85spi.c: Reorder functions with primitives at the top
Reshuffle file with no semantic changes, this avoids unnecessary prototypes for static member functions as to pave the way for further cleanups as well as an easier to parse implementation. BUG=b:172876667 TEST=builds Change-Id: Idf4241c92d90c28dd4f4ec3b7d66bda50801385a Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/47657 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
eeef125b39
commit
5783c04585
179
it85spi.c
179
it85spi.c
@ -223,98 +223,6 @@ static int it85xx_shutdown(void *data)
|
|||||||
return 0; /* FIXME: Should probably return something meaningful */
|
return 0; /* FIXME: Should probably return something meaningful */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int it85xx_spi_common_init(struct superio s)
|
|
||||||
{
|
|
||||||
chipaddr base;
|
|
||||||
|
|
||||||
msg_pdbg("%s():%d superio.vendor=0x%02x\n", __func__, __LINE__,
|
|
||||||
s.vendor);
|
|
||||||
|
|
||||||
if (register_shutdown(it85xx_shutdown, NULL))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
#ifdef LPC_IO
|
|
||||||
/* Get LPCPNP of SHM. That's big-endian. */
|
|
||||||
sio_write(s.port, LDNSEL, 0x0F); /* Set LDN to SHM (0x0F) */
|
|
||||||
shm_io_base = (sio_read(s.port, SHM_IO_BAR0) << 8) +
|
|
||||||
sio_read(s.port, SHM_IO_BAR1);
|
|
||||||
msg_pdbg("%s():%d shm_io_base=0x%04x\n", __func__, __LINE__,
|
|
||||||
shm_io_base);
|
|
||||||
|
|
||||||
/* These pointers are not used directly. They will be send to EC's
|
|
||||||
* register for indirect access. */
|
|
||||||
base = 0xFFFFF000;
|
|
||||||
ce_high = ((unsigned char *)base) + 0xE00; /* 0xFFFFFE00 */
|
|
||||||
ce_low = ((unsigned char *)base) + 0xD00; /* 0xFFFFFD00 */
|
|
||||||
|
|
||||||
/* pre-set indirect-access registers since in most of cases they are
|
|
||||||
* 0xFFFFxx00. */
|
|
||||||
INDIRECT_A0(shm_io_base, base & 0xFF);
|
|
||||||
INDIRECT_A2(shm_io_base, (base >> 16) & 0xFF);
|
|
||||||
INDIRECT_A3(shm_io_base, (base >> 24));
|
|
||||||
#endif
|
|
||||||
#ifdef LPC_MEMORY
|
|
||||||
/* FIXME: We should block accessing that region for anything else.
|
|
||||||
* Major TODO here, and it will be a lot of work.
|
|
||||||
*/
|
|
||||||
base = (chipaddr)physmap("it85 communication", 0xFFFFF000, 0x1000);
|
|
||||||
if (base == (chipaddr)ERROR_PTR)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
msg_pdbg("%s():%d base=0x%08x\n", __func__, __LINE__,
|
|
||||||
(unsigned int)base);
|
|
||||||
ce_high = (unsigned char *)(base + 0xE00); /* 0xFFFFFE00 */
|
|
||||||
ce_low = (unsigned char *)(base + 0xD00); /* 0xFFFFFD00 */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int it85xx_spi_send_command(const struct flashctx *flash,
|
|
||||||
unsigned int writecnt, unsigned int readcnt,
|
|
||||||
const unsigned char *writearr,
|
|
||||||
unsigned char *readarr);
|
|
||||||
|
|
||||||
static const struct spi_master spi_master_it85xx = {
|
|
||||||
.max_data_read = 64,
|
|
||||||
.max_data_write = 64,
|
|
||||||
.command = it85xx_spi_send_command,
|
|
||||||
.multicommand = default_spi_send_multicommand,
|
|
||||||
.read = default_spi_read,
|
|
||||||
.write_256 = default_spi_write_256,
|
|
||||||
.write_aai = default_spi_write_aai,
|
|
||||||
};
|
|
||||||
|
|
||||||
int it85xx_spi_init(struct superio s)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!(internal_buses_supported & BUS_FWH)) {
|
|
||||||
msg_pdbg("%s():%d buses not support FWH\n", __func__, __LINE__);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
ret = it85xx_spi_common_init(s);
|
|
||||||
msg_pdbg("FWH: %s():%d ret=%d\n", __func__, __LINE__, ret);
|
|
||||||
if (!ret) {
|
|
||||||
msg_pdbg("%s: internal_buses_supported=0x%x\n", __func__,
|
|
||||||
internal_buses_supported);
|
|
||||||
/* Check for FWH because IT85 listens to FWH cycles.
|
|
||||||
* FIXME: The big question is whether FWH cycles are necessary
|
|
||||||
* for communication even if LPC_IO is defined.
|
|
||||||
*/
|
|
||||||
if (internal_buses_supported & BUS_FWH)
|
|
||||||
msg_pdbg("Registering IT85 SPI.\n");
|
|
||||||
/* FIXME: Really leave FWH enabled? We can't use this region
|
|
||||||
* anymore since accessing it would mess up IT85 communication.
|
|
||||||
* If we decide to disable FWH for this region, we should print
|
|
||||||
* a debug message about it.
|
|
||||||
*/
|
|
||||||
/* Set this as SPI controller. */
|
|
||||||
register_spi_master(&spi_master_it85xx);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* According to ITE 8502 document, the procedure to follow mode is following:
|
/* According to ITE 8502 document, the procedure to follow mode is following:
|
||||||
* 1. write 0x00 to LPC/FWH address 0xffff_fexxh (drive CE# high)
|
* 1. write 0x00 to LPC/FWH address 0xffff_fexxh (drive CE# high)
|
||||||
* 2. write data to LPC/FWH address 0xffff_fdxxh (drive CE# low and MOSI
|
* 2. write data to LPC/FWH address 0xffff_fdxxh (drive CE# low and MOSI
|
||||||
@ -369,4 +277,91 @@ static int it85xx_spi_send_command(const struct flashctx *flash,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct spi_master spi_master_it85xx = {
|
||||||
|
.max_data_read = 64,
|
||||||
|
.max_data_write = 64,
|
||||||
|
.command = it85xx_spi_send_command,
|
||||||
|
.multicommand = default_spi_send_multicommand,
|
||||||
|
.read = default_spi_read,
|
||||||
|
.write_256 = default_spi_write_256,
|
||||||
|
.write_aai = default_spi_write_aai,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int it85xx_spi_common_init(struct superio s)
|
||||||
|
{
|
||||||
|
chipaddr base;
|
||||||
|
|
||||||
|
msg_pdbg("%s():%d superio.vendor=0x%02x\n", __func__, __LINE__,
|
||||||
|
s.vendor);
|
||||||
|
|
||||||
|
if (register_shutdown(it85xx_shutdown, NULL))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
#ifdef LPC_IO
|
||||||
|
/* Get LPCPNP of SHM. That's big-endian. */
|
||||||
|
sio_write(s.port, LDNSEL, 0x0F); /* Set LDN to SHM (0x0F) */
|
||||||
|
shm_io_base = (sio_read(s.port, SHM_IO_BAR0) << 8) +
|
||||||
|
sio_read(s.port, SHM_IO_BAR1);
|
||||||
|
msg_pdbg("%s():%d shm_io_base=0x%04x\n", __func__, __LINE__,
|
||||||
|
shm_io_base);
|
||||||
|
|
||||||
|
/* These pointers are not used directly. They will be send to EC's
|
||||||
|
* register for indirect access. */
|
||||||
|
base = 0xFFFFF000;
|
||||||
|
ce_high = ((unsigned char *)base) + 0xE00; /* 0xFFFFFE00 */
|
||||||
|
ce_low = ((unsigned char *)base) + 0xD00; /* 0xFFFFFD00 */
|
||||||
|
|
||||||
|
/* pre-set indirect-access registers since in most of cases they are
|
||||||
|
* 0xFFFFxx00. */
|
||||||
|
INDIRECT_A0(shm_io_base, base & 0xFF);
|
||||||
|
INDIRECT_A2(shm_io_base, (base >> 16) & 0xFF);
|
||||||
|
INDIRECT_A3(shm_io_base, (base >> 24));
|
||||||
|
#endif
|
||||||
|
#ifdef LPC_MEMORY
|
||||||
|
/* FIXME: We should block accessing that region for anything else.
|
||||||
|
* Major TODO here, and it will be a lot of work.
|
||||||
|
*/
|
||||||
|
base = (chipaddr)physmap("it85 communication", 0xFFFFF000, 0x1000);
|
||||||
|
if (base == (chipaddr)ERROR_PTR)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
msg_pdbg("%s():%d base=0x%08x\n", __func__, __LINE__,
|
||||||
|
(unsigned int)base);
|
||||||
|
ce_high = (unsigned char *)(base + 0xE00); /* 0xFFFFFE00 */
|
||||||
|
ce_low = (unsigned char *)(base + 0xD00); /* 0xFFFFFD00 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int it85xx_spi_init(struct superio s)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!(internal_buses_supported & BUS_FWH)) {
|
||||||
|
msg_pdbg("%s():%d buses not support FWH\n", __func__, __LINE__);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
ret = it85xx_spi_common_init(s);
|
||||||
|
msg_pdbg("FWH: %s():%d ret=%d\n", __func__, __LINE__, ret);
|
||||||
|
if (!ret) {
|
||||||
|
msg_pdbg("%s: internal_buses_supported=0x%x\n", __func__,
|
||||||
|
internal_buses_supported);
|
||||||
|
/* Check for FWH because IT85 listens to FWH cycles.
|
||||||
|
* FIXME: The big question is whether FWH cycles are necessary
|
||||||
|
* for communication even if LPC_IO is defined.
|
||||||
|
*/
|
||||||
|
if (internal_buses_supported & BUS_FWH)
|
||||||
|
msg_pdbg("Registering IT85 SPI.\n");
|
||||||
|
/* FIXME: Really leave FWH enabled? We can't use this region
|
||||||
|
* anymore since accessing it would mess up IT85 communication.
|
||||||
|
* If we decide to disable FWH for this region, we should print
|
||||||
|
* a debug message about it.
|
||||||
|
*/
|
||||||
|
/* Set this as SPI controller. */
|
||||||
|
register_spi_master(&spi_master_it85xx);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user