• Serge Semin's avatar
    ata: ahci: Introduce firmware-specific caps initialization · 18ee7c49
    Serge Semin authored
    There are systems with no BIOS or comprehensive embedded firmware which
    could be able to properly initialize the SATA AHCI controller
    platform-specific capabilities. In that case a good alternative to having
    a clever bootloader is to create a device tree node with the properties
    well describing all the AHCI-related platform specifics. All the settings
    which are normally detected and marked as available in the HBA and its
    ports capabilities fields [1] could be defined in the platform DTB by
    means of a set of the dedicated properties. Such approach perfectly fits
    to the DTB-philosophy - to provide hardware/platform description.
    
    So here we suggest to extend the SATA AHCI device tree bindings with two
    additional DT-properties:
    1) "hba-cap" - HBA platform generic capabilities like:
       - SSS - Staggered Spin-up support.
       - SMPS - Mechanical Presence Switch support.
    2) "hba-port-cap" - HBA platform port capabilities like:
       - HPCP - Hot Plug Capable Port.
       - MPSP - Mechanical Presence Switch Attached to Port.
       - CPD - Cold Presence Detection.
       - ESP - External SATA Port.
       - FBSCP - FIS-based Switching Capable Port.
    All of these capabilities require to have a corresponding hardware
    configuration. Thus it's ok to have them defined in DTB.
    
    Even though the driver currently takes into account the state of the ESP
    and FBSCP flags state only, there is nothing wrong with having all of them
    supported by the generic AHCI library in order to have a complete OF-based
    platform-capabilities initialization procedure. These properties will be
    parsed in the ahci_platform_get_resources() method and their values will
    be stored in the saved_* fields of the ahci_host_priv structure, which in
    its turn then will be used to restore the H.CAP, H.PI and P#.CMD
    capability fields on device init and after HBA reset.
    
    Please note this modification concerns the HW-init HBA and its ports flags
    only, which are by specification [1] are supposed to be initialized by the
    BIOS/platform firmware/expansion ROM and which are normally declared in
    the one-time-writable-after-reset register fields. Even though these flags
    aren't supposed to be cleared after HBA reset some AHCI instances may
    violate that rule so we still need to perform the fields resetting after
    each reset. Luckily the corresponding functionality has already been
    partly implemented in the framework of the ahci_save_initial_config() and
    ahci_restore_initial_config() methods.
    
    [1] Serial ATA AHCI 1.3.1 Specification, p. 103
    Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
    18ee7c49
libahci.c 68.9 KB