ata: ahci: use abstract read/write functions uniformly
PATCH 1/16 ata: ahci: use abstract read/write functions uniformly
Currently those are used in some routines side by side with underlying functions with no apparent reason for it. Make their usage uniform, this cleans up code a bit and allows to remove unneeded variables.
--- drivers/ata/ahci.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/ata/ahci.c +7 -11
@@ -172,7 +172,7 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbufahci_port_write_f (ahci_port,PORT_CMD_ISSUE ,1 ); ret =wait_on_timeout (WAIT_DATAIO , - (readl (ahci_port->port_mmio +PORT_CMD_ISSUE ) &0x1 ) ==0 ); + (ahci_port_read (ahci_port,PORT_CMD_ISSUE ) &0x1 ) ==0 );if (ret)return -ETIMEDOUT ;
@@ -274,12 +274,9 @@ static int ahci_write(struct ata_port *ata, const void *buf, sector_t block,static int ahci_init_port (struct ahci_port *ahci_port) { -void __iomem *port_mmio;u32 val, cmd;int ret; - port_mmio = ahci_port->port_mmio; -/* make sure port is not active */ val =ahci_port_read (ahci_port,PORT_CMD );if (val & (PORT_CMD_LIST_ON |PORT_CMD_FIS_ON |PORT_CMD_FIS_RX |PORT_CMD_START )) {
@@ -375,16 +372,16 @@ static int ahci_init_port(struct ahci_port *ahci_port)ahci_port_info (ahci_port,"Spinning up device...\n" ); ret =wait_on_timeout (WAIT_SPINUP , - ((readl (port_mmio +PORT_TFDATA ) & + ((ahci_port_read (ahci_port,PORT_TFDATA ) & (ATA_STATUS_BUSY |ATA_STATUS_DRQ )) ==0 ) - || ((readl (port_mmio +PORT_SCR_STAT ) &0xf ) ==1 )); + || ((ahci_port_read (ahci_port,PORT_SCR_STAT ) &0xf ) ==1 ));if (ret) {ahci_port_info (ahci_port,"timeout.\n" ); ret = -ENODEV ; goto err_init; } -if ((readl (port_mmio +PORT_SCR_STAT ) &0xf ) ==1 ) { +if ((ahci_port_read (ahci_port,PORT_SCR_STAT ) &0xf ) ==1 ) {ahci_port_info (ahci_port,"down.\n" ); ret = -ENODEV ; goto err_init;
@@ -570,7 +567,6 @@ static int ahci_detect(struct device_d *dev)int ahci_add_host (struct ahci_device *ahci) { -u8 *mmio = (u8 *)ahci->mmio_base;u32 tmp, cap_save;int i, ret;
@@ -584,7 +580,7 @@ int ahci_add_host(struct ahci_device *ahci)ahci_debug (ahci,"ahci_host_init: start\n" ); - cap_save =readl (mmio +HOST_CAP ); + cap_save =ahci_ioread (ahci,HOST_CAP ); cap_save &= ((1 <<28 ) | (1 <<17 )); cap_save |= (1 <<27 );/* Staggered Spin-up. Not needed. */
@@ -597,7 +593,7 @@ int ahci_add_host(struct ahci_device *ahci)* reset must complete within 1 second, or * the hardware should be considered fried. */ - ret =wait_on_timeout (SECOND , (readl (mmio +HOST_CTL ) &HOST_RESET ) ==0 ); + ret =wait_on_timeout (SECOND , (ahci_ioread (ahci,HOST_CTL ) &HOST_RESET ) ==0 );if (ret) {ahci_debug (ahci,"controller reset failed (0x%x)\n" , tmp);return -ENODEV ;
@@ -620,7 +616,7 @@ int ahci_add_host(struct ahci_device *ahci) ahci_port->num = i; ahci_port->ahci = ahci; ahci_port->ata.dev = ahci->dev; - ahci_port->port_mmio =ahci_port_base (mmio, i); + ahci_port->port_mmio =ahci_port_base (ahci->mmio_base, i); ahci_port->ata.ops = &ahci_ops;ata_port_register (&ahci_port->ata); }
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/16 ata: ahci: replace magic numbers with named constants
--- drivers/ata/ahci.c | 21 +++++++++++---------- drivers/ata/ahci.h | 12 ++++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-)
drivers/ata/ahci.c +11 -10
@@ -101,7 +101,7 @@ static inline void __iomem *ahci_port_base(void __iomem *base, int port)static int ahci_link_ok (struct ahci_port *ahci_port,int verbose) { -u32 val =ahci_port_read (ahci_port,PORT_SCR_STAT ) &0xf ; +u32 val =ahci_port_read (ahci_port,PORT_SCR_STAT ) &PORT_SCR_STAT_DET ;if (val ==0x3 )return true;
@@ -166,7 +166,7 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbuf sg_count =ahci_fill_sg (ahci_port, rbuf ? rbuf : wbuf, buf_len); opts = (fis_len >>2 ) | (sg_count <<16 );if (wbuf) - opts |=1 <<6 ; + opts |=CMD_LIST_OPTS_WRITE ;ahci_fill_cmd_slot (ahci_port, opts);ahci_port_write_f (ahci_port,PORT_CMD_ISSUE ,1 );
@@ -355,7 +355,7 @@ static int ahci_init_port(struct ahci_port *ahci_port)* rarely has it taken between 1-2 ms. Never seen it above 2 ms. */ ret =wait_on_timeout (WAIT_LINKUP , - (ahci_port_read (ahci_port,PORT_SCR_STAT ) &0xf ) ==0x3 ); + (ahci_port_read (ahci_port,PORT_SCR_STAT ) &PORT_SCR_STAT_DET ) ==0x3 );if (ret) {ahci_port_info (ahci_port,"SATA link timeout\n" ); ret = -ETIMEDOUT ;
@@ -373,15 +373,16 @@ static int ahci_init_port(struct ahci_port *ahci_port) ret =wait_on_timeout (WAIT_SPINUP , ((ahci_port_read (ahci_port,PORT_TFDATA ) & - (ATA_STATUS_BUSY |ATA_STATUS_DRQ )) ==0 ) - || ((ahci_port_read (ahci_port,PORT_SCR_STAT ) &0xf ) ==1 )); + (ATA_STATUS_BUSY |ATA_STATUS_DRQ )) ==0 ) || + ((ahci_port_read (ahci_port,PORT_SCR_STAT ) & +PORT_SCR_STAT_DET ) ==1 ));if (ret) {ahci_port_info (ahci_port,"timeout.\n" ); ret = -ENODEV ; goto err_init; } -if ((ahci_port_read (ahci_port,PORT_SCR_STAT ) &0xf ) ==1 ) { +if ((ahci_port_read (ahci_port,PORT_SCR_STAT ) &PORT_SCR_STAT_DET ) ==1 ) {ahci_port_info (ahci_port,"down.\n" ); ret = -ENODEV ; goto err_init;
@@ -408,7 +409,7 @@ static int ahci_init_port(struct ahci_port *ahci_port)ahci_port_debug (ahci_port,"status: 0x%08x\n" , val); -if ((val &0xf ) ==0x03 ) +if ((val &PORT_SCR_STAT_DET ) ==0x3 )return 0 ; ret = -ENODEV ;
@@ -581,8 +582,8 @@ int ahci_add_host(struct ahci_device *ahci)ahci_debug (ahci,"ahci_host_init: start\n" ); cap_save =ahci_ioread (ahci,HOST_CAP ); - cap_save &= ((1 <<28 ) | (1 <<17 )); - cap_save |= (1 <<27 );/* Staggered Spin-up. Not needed. */ + cap_save &= (HOST_SMPS |HOST_SPM ); + cap_save |=HOST_SSS ;/* Staggered Spin-up. Not needed. */ /* global controller reset */ tmp =ahci_ioread (ahci,HOST_CTL );
@@ -605,7 +606,7 @@ int ahci_add_host(struct ahci_device *ahci) ahci->cap =ahci_ioread (ahci,HOST_CAP ); ahci->port_map =ahci_ioread (ahci,HOST_PORTS_IMPL ); - ahci->n_ports = (ahci->cap &0x1f ) +1 ; + ahci->n_ports = (ahci->cap &HOST_NP ) +1 ;ahci_debug (ahci,"cap 0x%x port_map 0x%x n_ports %d\n" , ahci->cap, ahci->port_map, ahci->n_ports);
drivers/ata/ahci.h +12 -0
@@ -33,6 +33,12 @@#define HOST_VERSION 0x10/* AHCI spec. version compliancy */ #define HOST_CAP2 0x24/* host capabilities, extended */ +/* HOST_CAP bits */ +#define HOST_SMPS (1 << 28)/* supports mechanical presence switch */ +#define HOST_SSS (1 << 27)/* supports staggered spin-up */ +#define HOST_SPM (1 << 17)/* supports port multiplier */ +#define HOST_NP (0x1f << 0)/* number of ports */ +/* HOST_CTL bits */ #define HOST_RESET (1 << 0)/* reset controller; self-clear */ #define HOST_IRQ_EN (1 << 1)/* global IRQ enable */
@@ -98,6 +104,9 @@#define PORT_CMD_ICC_PARTIAL (0x2 << 28)/* Put i/f in partial state */ #define PORT_CMD_ICC_SLUMBER (0x6 << 28)/* Put i/f in slumber state */ +/* PORT_SCR_STAT bits */ +#define PORT_SCR_STAT_DET (0xf << 0)/* device detection */ +#define AHCI_MAX_PORTS 32/* SETFEATURES stuff */
@@ -130,6 +139,9 @@#define ATA_FLAG_PIO_DMA (1 << 8)/* PIO cmds via DMA */ #define ATA_FLAG_NO_ATAPI (1 << 11)/* No ATAPI support */ +/* Command list entry DW0 bits */ +#define CMD_LIST_OPTS_WRITE (1 << 6)/* the direction is a device write */ +struct ahci_device ;struct ahci_port {
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/16 ata: ahci: fix missing whitespace in ahci_add_host()
In reply to Denis Orlov--- drivers/ata/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/ahci.c +1 -1
@@ -596,7 +596,7 @@ int ahci_add_host(struct ahci_device *ahci)*/ ret =wait_on_timeout (SECOND , (ahci_ioread (ahci,HOST_CTL ) &HOST_RESET ) ==0 );if (ret) { -ahci_debug (ahci,"controller reset failed (0x%x)\n" , tmp); +ahci_debug (ahci,"controller reset failed (0x%x)\n" , tmp);return -ENODEV ; }
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/16 ata: ahci: simplify fis structure creation
In reply to Denis Orlov--- drivers/ata/ahci.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
drivers/ata/ahci.c +9 -14
@@ -192,14 +192,12 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbufstatic int ahci_read_id (struct ata_port *ata,void *buf) { struct ahci_port *ahci = container_of(ata, struct ahci_port, ata); -u8 fis[20 ]; - -memset (fis,0 ,sizeof (fis)); -/* Construct the FIS */ - fis[0 ] =0x27 ;/* Host to device FIS. */ - fis[1 ] =1 <<7 ;/* Command FIS. */ - fis[2 ] =ATA_CMD_ID_ATA ;/* Command byte. */ +u8 fis[20 ] = { +0x27 ,/* Host to device FIS. */ +1 <<7 ,/* Command FIS. */ +ATA_CMD_ID_ATA /* Command byte. */ + };return ahci_io (ahci, fis,sizeof (fis), buf,NULL ,SECTOR_SIZE ); }
@@ -208,16 +206,13 @@ static int ahci_rw(struct ata_port *ata, void *rbuf, const void *wbuf, sector_t block, blkcnt_t num_blocks) { struct ahci_port *ahci = container_of(ata, struct ahci_port, ata); -u8 fis[20 ]; +u8 fis[20 ] = { +0x27 ,/* Host to device FIS. */ +1 <<7 /* Command FIS. */ + };int ret;int lba48 =ata_id_has_lba48 (ata->id); -memset (fis,0 ,sizeof (fis)); - -/* Construct the FIS */ - fis[0 ] =0x27 ;/* Host to device FIS. */ - fis[1 ] =1 <<7 ;/* Command FIS. */ -/* Command byte. */ if (lba48) fis[2 ] = wbuf ?ATA_CMD_WRITE_EXT :ATA_CMD_READ_EXT ;
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 5/16 ata: ahci: do not ignore dma handles
In reply to Denis OrlovThey represent addresses from the device side and should be used instead of cpu side ones when populating device registers than hold addresses.
--- drivers/ata/ahci.c | 21 ++++++++++++--------- drivers/ata/ahci.h | 3 +++ 2 files changed, 15 insertions(+), 9 deletions(-)
drivers/ata/ahci.c +12 -9
@@ -117,7 +117,7 @@ static void ahci_fill_cmd_slot(struct ahci_port *ahci_port, u32 opts) ahci_port->cmd_slot->opts =cpu_to_le32 (opts); ahci_port->cmd_slot->status =0 ; ahci_port->cmd_slot->tbl_addr = -cpu_to_le32 ((unsigned long )ahci_port->cmd_tbl &0xffffffff ); +cpu_to_le32 (ahci_port->cmd_tbl_dma &0xffffffff ); ahci_port->cmd_slot->tbl_addr_hi =0 ; }
@@ -292,7 +292,7 @@ static int ahci_init_port(struct ahci_port *ahci_port)* 32 bytes each in size */ ahci_port->cmd_slot =dma_alloc_coherent (AHCI_CMD_SLOT_SZ *32 , -DMA_ADDRESS_BROKEN ); + &ahci_port->cmd_slot_dma);if (!ahci_port->cmd_slot) { ret = -ENOMEM ; goto err_alloc;
@@ -304,7 +304,7 @@ static int ahci_init_port(struct ahci_port *ahci_port)* Second item: Received-FIS area */ ahci_port->rx_fis = (unsigned long )dma_alloc_coherent (AHCI_RX_FIS_SZ , -DMA_ADDRESS_BROKEN ); + &ahci_port->rx_fis_dma);if (!ahci_port->rx_fis) { ret = -ENOMEM ; goto err_alloc1;
@@ -315,7 +315,7 @@ static int ahci_init_port(struct ahci_port *ahci_port)* and its scatter-gather table */ ahci_port->cmd_tbl =dma_alloc_coherent (AHCI_CMD_TBL_SZ , -DMA_ADDRESS_BROKEN ); + &ahci_port->cmd_tbl_dma);if (!ahci_port->cmd_tbl) { ret = -ENOMEM ; goto err_alloc2;
@@ -325,8 +325,8 @@ static int ahci_init_port(struct ahci_port *ahci_port) ahci_port->cmd_tbl_sg = ahci_port->cmd_tbl +AHCI_CMD_TBL_HDR_SZ ; -ahci_port_write_f (ahci_port,PORT_LST_ADDR , (u32 )ahci_port->cmd_slot); -ahci_port_write_f (ahci_port,PORT_FIS_ADDR , ahci_port->rx_fis); +ahci_port_write_f (ahci_port,PORT_LST_ADDR , ahci_port->cmd_slot_dma); +ahci_port_write_f (ahci_port,PORT_FIS_ADDR , ahci_port->rx_fis_dma);/* * Add the spinup command to whatever mode bits may
@@ -410,11 +410,14 @@ static int ahci_init_port(struct ahci_port *ahci_port) ret = -ENODEV ; err_init: -dma_free_coherent (ahci_port->cmd_tbl,0 ,AHCI_CMD_TBL_SZ ); +dma_free_coherent (ahci_port->cmd_tbl, ahci_port->cmd_tbl_dma, +AHCI_CMD_TBL_SZ ); err_alloc2: -dma_free_coherent ((void *)ahci_port->rx_fis,0 ,AHCI_RX_FIS_SZ ); +dma_free_coherent ((void *)ahci_port->rx_fis, ahci_port->rx_fis_dma, +AHCI_RX_FIS_SZ ); err_alloc1: -dma_free_coherent (ahci_port->cmd_slot,0 ,AHCI_CMD_SLOT_SZ *32 ); +dma_free_coherent (ahci_port->cmd_slot, ahci_port->cmd_slot_dma, +AHCI_CMD_SLOT_SZ *32 ); err_alloc:return ret; }
drivers/ata/ahci.h +3 -0
@@ -151,9 +151,12 @@ struct ahci_port {unsigned flags;void __iomem *port_mmio;struct ahci_cmd_hdr *cmd_slot; +dma_addr_t cmd_slot_dma;struct ahci_sg *cmd_tbl_sg;void *cmd_tbl; +dma_addr_t cmd_tbl_dma;u32 rx_fis; +dma_addr_t rx_fis_dma; };struct ahci_device {
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 6/16 ata: ahci: adjust debug messages in ahci_init_port()
In reply to Denis OrlovThe output was a bit misleading, not displaying physical addresses while for some reason using "dma" to specify a variable in one case. Make it print both types of addresses.
--- drivers/ata/ahci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ata/ahci.c +4 -2
@@ -298,7 +298,8 @@ static int ahci_init_port(struct ahci_port *ahci_port) goto err_alloc; } -ahci_port_debug (ahci_port,"cmd_slot = 0x%x\n" , (unsigned )ahci_port->cmd_slot); +ahci_port_debug (ahci_port,"cmd_slot = 0x%p (0x%pa)\n" , + ahci_port->cmd_slot, ahci_port->cmd_slot_dma);/* * Second item: Received-FIS area
@@ -321,7 +322,8 @@ static int ahci_init_port(struct ahci_port *ahci_port) goto err_alloc2; } -ahci_port_debug (ahci_port,"cmd_tbl_dma = 0x%p\n" , ahci_port->cmd_tbl); +ahci_port_debug (ahci_port,"cmd_tbl = 0x%p (0x%pa)\n" , + ahci_port->cmd_tbl, ahci_port->cmd_tbl_dma); ahci_port->cmd_tbl_sg = ahci_port->cmd_tbl +AHCI_CMD_TBL_HDR_SZ ;
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 7/16 ata: ahci: correct named constants values and names
In reply to Denis OrlovThis gives more clear names to some of the macros that designate the sizes of various memory structures and fixes a mistake in one of them. The command table item was regarded as taking 32 bytes in size while it is actually supposed to only take 16 bytes according to the spec. This also changes a somewhat misleading comment that calls the command list a command table. There is a cmt_tbl field that actually holds a pointer to a different structure that is called a command table in the specification, so it seems better to more clearly disambiguate them.
--- drivers/ata/ahci.c | 6 +++--- drivers/ata/ahci.h | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-)
drivers/ata/ahci.c +3 -3
@@ -288,10 +288,10 @@ static int ahci_init_port(struct ahci_port *ahci_port) }/* -* First item in chunk of DMA memory: 32-slot command table, +* First item in chunk of DMA memory: 32-slot command list, * 32 bytes each in size */ - ahci_port->cmd_slot =dma_alloc_coherent (AHCI_CMD_SLOT_SZ *32 , + ahci_port->cmd_slot =dma_alloc_coherent (AHCI_CMD_LIST_SZ , &ahci_port->cmd_slot_dma);if (!ahci_port->cmd_slot) { ret = -ENOMEM ;
@@ -419,7 +419,7 @@ err_alloc2: AHCI_RX_FIS_SZ); err_alloc1:dma_free_coherent (ahci_port->cmd_slot, ahci_port->cmd_slot_dma, -AHCI_CMD_SLOT_SZ *32 ); +AHCI_CMD_LIST_SZ ); err_alloc:return ret; }
drivers/ata/ahci.h +6 -4
@@ -10,13 +10,15 @@#define AHCI_PCI_BAR 0x24#define AHCI_MAX_SG 56/* hardware max is 64K */ #define AHCI_CMD_SLOT_SZ 32 -#define AHCI_MAX_CMD_SLOT 32 +#define AHCI_MAX_CMDS 32 +#define AHCI_CMD_LIST_SZ (AHCI_CMD_SLOT_SZ * AHCI_MAX_CMDS)#define AHCI_RX_FIS_SZ 256#define AHCI_CMD_TBL_HDR_SZ 0x80#define AHCI_CMD_TBL_CDB 0x40 -#define AHCI_CMD_TBL_SZ AHCI_CMD_TBL_HDR_SZ + (AHCI_MAX_SG * 32) -#define AHCI_PORT_PRIV_DMA_SZ (AHCI_CMD_SLOT_SZ * AHCI_MAX_CMD_SLOT + \ - AHCI_CMD_TBL_SZ + AHCI_RX_FIS_SZ) +#define AHCI_CMD_TBL_ITM_SZ 16 +#define AHCI_CMD_TBL_SZ (AHCI_CMD_TBL_HDR_SZ + (AHCI_MAX_SG * AHCI_CMD_TBL_ITM_SZ)) +#define AHCI_PORT_PRIV_DMA_SZ (AHCI_CMD_LIST_SZ + AHCI_CMD_TBL_SZ + AHCI_RX_FIS_SZ) +#define AHCI_CMD_ATAPI (1 << 5)#define AHCI_CMD_WRITE (1 << 6)#define AHCI_CMD_PREFETCH (1 << 7)
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 8/16 ata: ahci: properly fill scatter/gather table
In reply to Denis OrlovWe are supposed to populate a table, but instead we were just overwriting the same entry over and over in a loop.
--- drivers/ata/ahci.c | 1 + 1 file changed, 1 insertion(+)
drivers/ata/ahci.c +1 -0
@@ -139,6 +139,7 @@ static int ahci_fill_sg(struct ahci_port *ahci_port, const void *buf, int buf_le buf_len -= now; buf += now; + ahci_sg++; }return sg_count;
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 9/16 ata: ahci: use named constants for capabilities bits
In reply to Denis Orlov--- drivers/ata/ahci.c | 51 +++++++++++++++++++++++----------------------- drivers/ata/ahci.h | 30 +++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 29 deletions(-)
drivers/ata/ahci.c +26 -25
@@ -500,7 +500,7 @@ void ahci_print_info(struct ahci_device *ahci) cap2 =ahci_ioread (ahci,HOST_CAP2 ); impl = ahci->port_map; - speed = (cap >>20 ) &0xf ; + speed = (cap &HOST_CAP_ISS ) >>20 ;if (speed ==1 ) speed_s ="1.5" ;else if (speed ==2 )
@@ -518,32 +518,33 @@ void ahci_print_info(struct ahci_device *ahci) (vers >>16 ) &0xff , (vers >>8 ) &0xff , vers &0xff , - ((cap >> 8) & 0x1f) + 1, (cap & 0x1f) + 1, speed_s, impl, scc_s); + ((cap &HOST_CAP_NCS ) >>8 ) +1 , + (cap & HOST_CAP_NP) + 1, speed_s, impl, scc_s);printf ("flags: " "%s%s%s%s%s%s%s" "%s%s%s%s%s%s%s" "%s%s%s%s%s%s\n" , - cap & (1 <<31 ) ?"64bit " :"" , - cap & (1 <<30 ) ?"ncq " :"" , - cap & (1 <<28 ) ?"ilck " :"" , - cap & (1 <<27 ) ?"stag " :"" , - cap & (1 <<26 ) ?"pm " :"" , - cap & (1 <<25 ) ?"led " :"" , - cap & (1 <<24 ) ?"clo " :"" , - cap & (1 <<19 ) ?"nz " :"" , - cap & (1 <<18 ) ?"only " :"" , - cap & (1 <<17 ) ?"pmp " :"" , - cap & (1 <<16 ) ?"fbss " :"" , - cap & (1 <<15 ) ?"pio " :"" , - cap & (1 <<14 ) ?"slum " :"" , - cap & (1 <<13 ) ?"part " :"" , - cap & (1 <<7 ) ?"ccc " :"" , - cap & (1 <<6 ) ?"ems " :"" , - cap & (1 <<5 ) ?"sxs " :"" , - cap2 & (1 <<2 ) ?"apst " :"" , - cap2 & (1 <<1 ) ?"nvmp " :"" , - cap2 & (1 <<0 ) ?"boh " :"" ); + cap &HOST_CAP_64 ?"64bit " :"" , + cap &HOST_CAP_NCQ ?"ncq " :"" , + cap &HOST_CAP_SMPS ?"ilck " :"" , + cap &HOST_CAP_SSS ?"stag " :"" , + cap &HOST_CAP_ALPM ?"pm " :"" , + cap &HOST_CAP_LED ?"led " :"" , + cap &HOST_CAP_CLO ?"clo " :"" , + cap &HOST_CAP_RESERVED ?"nz " :"" , + cap &HOST_CAP_ONLY ?"only " :"" , + cap &HOST_CAP_SPM ?"pmp " :"" , + cap &HOST_CAP_FBS ?"fbss " :"" , + cap &HOST_CAP_PIO_MULTI ?"pio " :"" , + cap &HOST_CAP_SSC ?"slum " :"" , + cap &HOST_CAP_PART ?"part " :"" , + cap &HOST_CAP_CCC ?"ccc " :"" , + cap &HOST_CAP_EMS ?"ems " :"" , + cap &HOST_CAP_SXS ?"sxs " :"" , + cap2 &HOST_CAP2_APST ?"apst " :"" , + cap2 &HOST_CAP2_NVMHCI ?"nvmp " :"" , + cap2 &HOST_CAP2_BOH ?"boh " :"" ); }void ahci_info (struct device_d *dev)
@@ -583,8 +584,8 @@ int ahci_add_host(struct ahci_device *ahci)ahci_debug (ahci,"ahci_host_init: start\n" ); cap_save =ahci_ioread (ahci,HOST_CAP ); - cap_save &= (HOST_SMPS |HOST_SPM ); - cap_save |=HOST_SSS ;/* Staggered Spin-up. Not needed. */ + cap_save &= (HOST_CAP_SMPS |HOST_CAP_SPM ); + cap_save |=HOST_CAP_SSS ;/* Staggered Spin-up. Not needed. */ /* global controller reset */ tmp =ahci_ioread (ahci,HOST_CTL );
@@ -607,7 +608,7 @@ int ahci_add_host(struct ahci_device *ahci) ahci->cap =ahci_ioread (ahci,HOST_CAP ); ahci->port_map =ahci_ioread (ahci,HOST_PORTS_IMPL ); - ahci->n_ports = (ahci->cap &HOST_NP ) +1 ; + ahci->n_ports = (ahci->cap &HOST_CAP_NP ) +1 ;ahci_debug (ahci,"cap 0x%x port_map 0x%x n_ports %d\n" , ahci->cap, ahci->port_map, ahci->n_ports);
drivers/ata/ahci.h +26 -4
@@ -36,10 +36,32 @@#define HOST_CAP2 0x24/* host capabilities, extended */ /* HOST_CAP bits */ -#define HOST_SMPS (1 << 28)/* supports mechanical presence switch */ -#define HOST_SSS (1 << 27)/* supports staggered spin-up */ -#define HOST_SPM (1 << 17)/* supports port multiplier */ -#define HOST_NP (0x1f << 0)/* number of ports */ +#define HOST_CAP_64 (1 << 31)/* PCI DAC (64-bit DMA) support */ +#define HOST_CAP_NCQ (1 << 30)/* Native Command Queueing */ +#define HOST_CAP_SNTF (1 << 29)/* SNotification register */ +#define HOST_CAP_SMPS (1 << 28)/* Supports mechanical presence switch */ +#define HOST_CAP_SSS (1 << 27)/* Supports staggered spin-up */ +#define HOST_CAP_ALPM (1 << 26)/* Aggressive Link PM support */ +#define HOST_CAP_LED (1 << 25)/* Supports activity LED */ +#define HOST_CAP_CLO (1 << 24)/* Command List Override support */ +#define HOST_CAP_ISS (0xf << 20)/* Interface Speed Support */ +#define HOST_CAP_RESERVED (1 << 19)/* Reserved bit */ +#define HOST_CAP_ONLY (1 << 18)/* Supports AHCI mode only */ +#define HOST_CAP_SPM (1 << 17)/* Supports port multiplier */ +#define HOST_CAP_FBS (1 << 16)/* FIS-based switching support */ +#define HOST_CAP_PIO_MULTI (1 << 15)/* PIO multiple DRQ support */ +#define HOST_CAP_SSC (1 << 14)/* Slumber state capable */ +#define HOST_CAP_PART (1 << 13)/* Partial state capable */ +#define HOST_CAP_NCS (0x1f << 8)/* Number of Command Slots */ +#define HOST_CAP_CCC (1 << 7)/* Command Completion Coalescing */ +#define HOST_CAP_EMS (1 << 6)/* Enclosure Management support */ +#define HOST_CAP_SXS (1 << 5)/* Supports External SATA */ +#define HOST_CAP_NP (0x1f << 0)/* Number of ports */ + +/* HOST_CAP2 bits */ +#define HOST_CAP2_APST (1 << 2)/* Automatic partial to slumber */ +#define HOST_CAP2_NVMHCI (1 << 1)/* NVMHCI supported */ +#define HOST_CAP2_BOH (1 << 0)/* BIOS/OS handoff supported */ /* HOST_CTL bits */ #define HOST_RESET (1 << 0)/* reset controller; self-clear */
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 10/16 ata: ahci: map buffers properly
In reply to Denis OrlovUsing dma_sync_single_for_*() does not make sense in there - we are given a cpu side address of a buffer and need to actually map it for the device.
--- drivers/ata/ahci.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-)
drivers/ata/ahci.c +18 -19
@@ -121,7 +121,7 @@ static void ahci_fill_cmd_slot(struct ahci_port *ahci_port, u32 opts) ahci_port->cmd_slot->tbl_addr_hi =0 ; } -static int ahci_fill_sg (struct ahci_port *ahci_port,const void *buf,int buf_len) +static int ahci_fill_sg (struct ahci_port *ahci_port,dma_addr_t buf_dma,int buf_len) {struct ahci_sg *ahci_sg = ahci_port->cmd_tbl_sg;u32 sg_count;
@@ -133,12 +133,12 @@ static int ahci_fill_sg(struct ahci_port *ahci_port, const void *buf, int buf_lewhile (buf_len) {unsigned int now =min (AHCI_MAX_DATA_BYTE_COUNT , buf_len); - ahci_sg->addr =cpu_to_le32 ((u32 )buf); + ahci_sg->addr =cpu_to_le32 (buf_dma); ahci_sg->addr_hi =0 ; ahci_sg->flags_size =cpu_to_le32 (now -1 ); buf_len -= now; - buf += now; + buf_dma += now; ahci_sg++; }
@@ -151,20 +151,26 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbufu32 opts;int sg_count;int ret; +void *buf; +dma_addr_t buf_dma; +enum dma_data_direction dma_dir;if (!ahci_link_ok (ahci_port,1 ))return -EIO ; -if (wbuf) -dma_sync_single_for_device ((unsigned long )wbuf, buf_len, -DMA_TO_DEVICE ); -if (rbuf) -dma_sync_single_for_device ((unsigned long )rbuf, buf_len, -DMA_FROM_DEVICE ); +if (wbuf) { + buf = (void *)wbuf; + dma_dir =DMA_TO_DEVICE ; + }else { + buf = rbuf; + dma_dir =DMA_FROM_DEVICE ; + } + + buf_dma =dma_map_single (ahci_port->ahci->dev, buf, buf_len, dma_dir);memcpy ((unsigned char *)ahci_port->cmd_tbl, fis, fis_len); - sg_count =ahci_fill_sg (ahci_port, rbuf ? rbuf : wbuf, buf_len); + sg_count =ahci_fill_sg (ahci_port, buf_dma, buf_len); opts = (fis_len >>2 ) | (sg_count <<16 );if (wbuf) opts |=CMD_LIST_OPTS_WRITE ;
@@ -174,17 +180,10 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbuf ret =wait_on_timeout (WAIT_DATAIO , (ahci_port_read (ahci_port,PORT_CMD_ISSUE ) &0x1 ) ==0 ); -if (ret) -return -ETIMEDOUT ; -if (wbuf) -dma_sync_single_for_cpu ((unsigned long )wbuf, buf_len, -DMA_TO_DEVICE ); -if (rbuf) -dma_sync_single_for_cpu ((unsigned long )rbuf, buf_len, -DMA_FROM_DEVICE ); +dma_unmap_single (ahci_port->ahci->dev, buf_dma, buf_len, dma_dir); -return 0 ; +return ret; }/*
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 11/16 ata: ahci: use 64-bit addressing if available
In reply to Denis Orlov--- drivers/ata/ahci.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/ata/ahci.c +13 -6
@@ -117,8 +117,10 @@ static void ahci_fill_cmd_slot(struct ahci_port *ahci_port, u32 opts) ahci_port->cmd_slot->opts =cpu_to_le32 (opts); ahci_port->cmd_slot->status =0 ; ahci_port->cmd_slot->tbl_addr = -cpu_to_le32 (ahci_port->cmd_tbl_dma &0xffffffff ); - ahci_port->cmd_slot->tbl_addr_hi =0 ; +cpu_to_le32 (lower_32_bits (ahci_port->cmd_tbl_dma)); +if (ahci_port->ahci->cap &HOST_CAP_64 ) + ahci_port->cmd_slot->tbl_addr_hi = +cpu_to_le32 (upper_32_bits (ahci_port->cmd_tbl_dma)); }static int ahci_fill_sg (struct ahci_port *ahci_port,dma_addr_t buf_dma,int buf_len)
@@ -133,8 +135,9 @@ static int ahci_fill_sg(struct ahci_port *ahci_port, dma_addr_t buf_dma, int bufwhile (buf_len) {unsigned int now =min (AHCI_MAX_DATA_BYTE_COUNT , buf_len); - ahci_sg->addr =cpu_to_le32 (buf_dma); - ahci_sg->addr_hi =0 ; + ahci_sg->addr =cpu_to_le32 (lower_32_bits (buf_dma)); +if (ahci_port->ahci->cap &HOST_CAP_64 ) + ahci_sg->addr_hi =cpu_to_le32 (upper_32_bits (buf_dma)); ahci_sg->flags_size =cpu_to_le32 (now -1 ); buf_len -= now;
@@ -327,8 +330,12 @@ static int ahci_init_port(struct ahci_port *ahci_port) ahci_port->cmd_tbl_sg = ahci_port->cmd_tbl +AHCI_CMD_TBL_HDR_SZ ; -ahci_port_write_f (ahci_port,PORT_LST_ADDR , ahci_port->cmd_slot_dma); -ahci_port_write_f (ahci_port,PORT_FIS_ADDR , ahci_port->rx_fis_dma); +ahci_port_write_f (ahci_port,PORT_LST_ADDR ,lower_32_bits (ahci_port->cmd_slot_dma)); +if (ahci_port->ahci->cap &HOST_CAP_64 ) +ahci_port_write_f (ahci_port,PORT_LST_ADDR_HI ,upper_32_bits (ahci_port->cmd_slot_dma)); +ahci_port_write_f (ahci_port,PORT_FIS_ADDR ,lower_32_bits (ahci_port->rx_fis_dma)); +if (ahci_port->ahci->cap &HOST_CAP_64 ) +ahci_port_write_f (ahci_port,PORT_FIS_ADDR_HI ,upper_32_bits (ahci_port->rx_fis_dma));/* * Add the spinup command to whatever mode bits may
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 12/16 ata: ahci: make rx_fis field in ahci_port of type void*
In reply to Denis OrlovIt is supposed to represent a pointer so make it actually be one.
--- drivers/ata/ahci.c | 5 ++--- drivers/ata/ahci.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/ata/ahci.c +2 -3
@@ -307,8 +307,7 @@ static int ahci_init_port(struct ahci_port *ahci_port)/* * Second item: Received-FIS area */ - ahci_port->rx_fis = (unsigned long )dma_alloc_coherent (AHCI_RX_FIS_SZ , - &ahci_port->rx_fis_dma); + ahci_port->rx_fis =dma_alloc_coherent (AHCI_RX_FIS_SZ , &ahci_port->rx_fis_dma);if (!ahci_port->rx_fis) { ret = -ENOMEM ; goto err_alloc1;
@@ -422,7 +421,7 @@ err_init:dma_free_coherent (ahci_port->cmd_tbl, ahci_port->cmd_tbl_dma,AHCI_CMD_TBL_SZ ); err_alloc2: -dma_free_coherent ((void *)ahci_port->rx_fis, ahci_port->rx_fis_dma, +dma_free_coherent (ahci_port->rx_fis, ahci_port->rx_fis_dma,AHCI_RX_FIS_SZ ); err_alloc1: dma_free_coherent(ahci_port->cmd_slot, ahci_port->cmd_slot_dma,
drivers/ata/ahci.h +1 -1
@@ -179,7 +179,7 @@ struct ahci_port {struct ahci_sg *cmd_tbl_sg;void *cmd_tbl;dma_addr_t cmd_tbl_dma; -u32 rx_fis; +void *rx_fis;dma_addr_t rx_fis_dma; };
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 13/16 ata: ahci: add missing capability in ahci_print_info()
In reply to Denis Orlov--- drivers/ata/ahci.c | 1 + 1 file changed, 1 insertion(+)
drivers/ata/ahci.c +1 -0
@@ -532,6 +532,7 @@ void ahci_print_info(struct ahci_device *ahci)"%s%s%s%s%s%s\n" , cap &HOST_CAP_64 ?"64bit " :"" , cap &HOST_CAP_NCQ ?"ncq " :"" , + cap &HOST_CAP_SNTF ?"sntf " :"" , cap &HOST_CAP_SMPS ?"ilck " :"" , cap &HOST_CAP_SSS ?"stag " :"" , cap & HOST_CAP_ALPM ? "pm " : "",
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 14/16 ata: ahci: remove redundant cast in ahci_io()
In reply to Denis Orlov--- drivers/ata/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/ahci.c +1 -1
@@ -171,7 +171,7 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbuf buf_dma =dma_map_single (ahci_port->ahci->dev, buf, buf_len, dma_dir); -memcpy ((unsigned char *)ahci_port->cmd_tbl, fis, fis_len); +memcpy (ahci_port->cmd_tbl, fis, fis_len); sg_count =ahci_fill_sg (ahci_port, buf_dma, buf_len); opts = (fis_len >>2 ) | (sg_count <<16 );
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 15/16 ata: ahci: register only implemented ports
In reply to Denis OrlovThe value from the "ports implemented" register should be kept in mind when registering ports or detecting devices on them.
--- drivers/ata/ahci.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/ata/ahci.c +12 -3
@@ -563,11 +563,15 @@ void ahci_info(struct device_d *dev)static int ahci_detect (struct device_d *dev) {struct ahci_device *ahci = dev->priv; +int n_ports =max_t (int, ahci->n_ports,fls (ahci->port_map));int i; -for (i =0 ; i < ahci->n_ports; i++) { +for (i =0 ; i < n_ports; i++) {struct ahci_port *ahci_port = &ahci->ports[i]; +if (!(ahci->port_map & (1 << i))) +continue ; +ata_port_detect (&ahci_port->ata); }
@@ -577,7 +581,7 @@ static int ahci_detect(struct device_d *dev)int ahci_add_host (struct ahci_device *ahci) {u32 tmp, cap_save; -int i, ret; +int n_ports, i, ret; ahci->host_flags =ATA_FLAG_SATA |ATA_FLAG_NO_LEGACY
@@ -619,9 +623,14 @@ int ahci_add_host(struct ahci_device *ahci)ahci_debug (ahci,"cap 0x%x port_map 0x%x n_ports %d\n" , ahci->cap, ahci->port_map, ahci->n_ports); -for (i =0 ; i < ahci->n_ports; i++) { + n_ports =max_t (int, ahci->n_ports,fls (ahci->port_map)); + +for (i =0 ; i < n_ports; i++) {struct ahci_port *ahci_port = &ahci->ports[i]; +if (!(ahci->port_map & (1 << i))) +continue ; + ahci_port->num = i; ahci_port->ahci = ahci; ahci_port->ata.dev = ahci->dev;
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 16/16 ata: ahci: allocate memory in one call in ahci_init_port()
In reply to Denis OrlovMemory allocated with dma_alloc_coherent() is aligned by page size. Calling it multiple times leads to unnecessary fragmentation and overhead considering that we are actually able to allocate all the memory that we need at once by issuing only one call.
--- drivers/ata/ahci.c | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-)
drivers/ata/ahci.c +14 -26
@@ -273,6 +273,8 @@ static int ahci_write(struct ata_port *ata, const void *buf, sector_t block,static int ahci_init_port (struct ahci_port *ahci_port) {u32 val, cmd; +void *mem; +dma_addr_t mem_dma;int ret;/* make sure port is not active */
@@ -290,16 +292,17 @@ static int ahci_init_port(struct ahci_port *ahci_port)mdelay (500 ); } + mem =dma_alloc_coherent (AHCI_PORT_PRIV_DMA_SZ , &mem_dma); +if (!mem) { +return -ENOMEM ; + } +/* * First item in chunk of DMA memory: 32-slot command list, * 32 bytes each in size */ - ahci_port->cmd_slot =dma_alloc_coherent (AHCI_CMD_LIST_SZ , - &ahci_port->cmd_slot_dma); -if (!ahci_port->cmd_slot) { - ret = -ENOMEM ; - goto err_alloc; - } + ahci_port->cmd_slot = mem; + ahci_port->cmd_slot_dma = mem_dma;ahci_port_debug (ahci_port,"cmd_slot = 0x%p (0x%pa)\n" , ahci_port->cmd_slot, ahci_port->cmd_slot_dma);
@@ -307,22 +310,15 @@ static int ahci_init_port(struct ahci_port *ahci_port)/* * Second item: Received-FIS area */ - ahci_port->rx_fis =dma_alloc_coherent (AHCI_RX_FIS_SZ , &ahci_port->rx_fis_dma); -if (!ahci_port->rx_fis) { - ret = -ENOMEM ; - goto err_alloc1; - } + ahci_port->rx_fis = mem +AHCI_CMD_SLOT_SZ ; + ahci_port->rx_fis_dma = mem_dma +AHCI_CMD_SLOT_SZ ;/* * Third item: data area for storing a single command * and its scatter-gather table */ - ahci_port->cmd_tbl =dma_alloc_coherent (AHCI_CMD_TBL_SZ , - &ahci_port->cmd_tbl_dma); -if (!ahci_port->cmd_tbl) { - ret = -ENOMEM ; - goto err_alloc2; - } + ahci_port->cmd_tbl = mem +AHCI_CMD_SLOT_SZ +AHCI_RX_FIS_SZ ; + ahci_port->cmd_tbl_dma = mem_dma +AHCI_CMD_SLOT_SZ +AHCI_RX_FIS_SZ ;ahci_port_debug (ahci_port,"cmd_tbl = 0x%p (0x%pa)\n" , ahci_port->cmd_tbl, ahci_port->cmd_tbl_dma);
@@ -418,15 +414,7 @@ static int ahci_init_port(struct ahci_port *ahci_port) ret = -ENODEV ; err_init: -dma_free_coherent (ahci_port->cmd_tbl, ahci_port->cmd_tbl_dma, -AHCI_CMD_TBL_SZ ); -err_alloc2: -dma_free_coherent (ahci_port->rx_fis, ahci_port->rx_fis_dma, -AHCI_RX_FIS_SZ ); -err_alloc1: -dma_free_coherent (ahci_port->cmd_slot, ahci_port->cmd_slot_dma, -AHCI_CMD_LIST_SZ ); -err_alloc: +dma_free_coherent (mem, mem_dma,AHCI_PORT_PRIV_DMA_SZ );return ret; }
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 8 lines · Denis Orlov
Currently those are used in some routines side by side with underlying functions with no apparent reason for it. Make their usage uniform, this cleans up code a bit and allows to remove unneeded variables.
Signed-off-by Denis Orlov <[email protected]>--- drivers/ata/ahci.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
Applied all, thanks
Sascha
Quoted 86 lines
drivers/ata/ahci.c +7
-11@@ -172,7 +172,7 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbufahci_port_write_f (ahci_port,PORT_CMD_ISSUE ,1 ); ret =wait_on_timeout (WAIT_DATAIO , - (readl (ahci_port->port_mmio +PORT_CMD_ISSUE ) &0x1 ) ==0 ); + (ahci_port_read (ahci_port,PORT_CMD_ISSUE ) &0x1 ) ==0 );if (ret)return -ETIMEDOUT ;@@ -274,12 +274,9 @@ static int ahci_write(struct ata_port *ata, const void *buf, sector_t block,static int ahci_init_port (struct ahci_port *ahci_port) { -void __iomem *port_mmio;u32 val, cmd;int ret; - port_mmio = ahci_port->port_mmio; -/* make sure port is not active */ val =ahci_port_read (ahci_port,PORT_CMD );if (val & (PORT_CMD_LIST_ON |PORT_CMD_FIS_ON |PORT_CMD_FIS_RX |PORT_CMD_START )) {@@ -375,16 +372,16 @@ static int ahci_init_port(struct ahci_port *ahci_port)ahci_port_info (ahci_port,"Spinning up device...\n" ); ret =wait_on_timeout (WAIT_SPINUP , - ((readl (port_mmio +PORT_TFDATA ) & + ((ahci_port_read (ahci_port,PORT_TFDATA ) & (ATA_STATUS_BUSY |ATA_STATUS_DRQ )) ==0 ) - || ((readl (port_mmio +PORT_SCR_STAT ) &0xf ) ==1 )); + || ((ahci_port_read (ahci_port,PORT_SCR_STAT ) &0xf ) ==1 ));if (ret) {ahci_port_info (ahci_port,"timeout.\n" ); ret = -ENODEV ; goto err_init; } -if ((readl (port_mmio +PORT_SCR_STAT ) &0xf ) ==1 ) { +if ((ahci_port_read (ahci_port,PORT_SCR_STAT ) &0xf ) ==1 ) {ahci_port_info (ahci_port,"down.\n" ); ret = -ENODEV ; goto err_init;@@ -570,7 +567,6 @@ static int ahci_detect(struct device_d *dev)int ahci_add_host (struct ahci_device *ahci) { -u8 *mmio = (u8 *)ahci->mmio_base;u32 tmp, cap_save;int i, ret;@@ -584,7 +580,7 @@ int ahci_add_host(struct ahci_device *ahci)ahci_debug (ahci,"ahci_host_init: start\n" ); - cap_save =readl (mmio +HOST_CAP ); + cap_save =ahci_ioread (ahci,HOST_CAP ); cap_save &= ((1 <<28 ) | (1 <<17 )); cap_save |= (1 <<27 );/* Staggered Spin-up. Not needed. */ @@ -597,7 +593,7 @@ int ahci_add_host(struct ahci_device *ahci)* reset must complete within 1 second, or * the hardware should be considered fried. */ - ret =wait_on_timeout (SECOND , (readl (mmio +HOST_CTL ) &HOST_RESET ) ==0 ); + ret =wait_on_timeout (SECOND , (ahci_ioread (ahci,HOST_CTL ) &HOST_RESET ) ==0 );if (ret) {ahci_debug (ahci,"controller reset failed (0x%x)\n" , tmp);return -ENODEV ;@@ -620,7 +616,7 @@ int ahci_add_host(struct ahci_device *ahci) ahci_port->num = i; ahci_port->ahci = ahci; ahci_port->ata.dev = ahci->dev; - ahci_port->port_mmio =ahci_port_base (mmio, i); + ahci_port->port_mmio =ahci_port_base (ahci->mmio_base, i); ahci_port->ata.ops = &ahci_ops;ata_port_register (&ahci_port->ata); }Signature · 1 line
2.20.1
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox