Merge branch 'linus-4.14-rc4-acp-prereq' of git://people.freedesktop.org/~agd5f/linux...
authorDave Airlie <airlied@redhat.com>
Mon, 13 Nov 2017 19:53:39 +0000 (05:53 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 13 Nov 2017 19:53:39 +0000 (05:53 +1000)
This is a shared tree between drm and audio for some amd bits.

* 'linus-4.14-rc4-acp-prereq' of git://people.freedesktop.org/~agd5f/linux:
  drm/amdgpu Moving amdgpu asic types to a separate file
  ASoC: AMD: Added asic_type as ACP DMA driver platform data
  drm/amd/amdgpu: Added asic_type as ACP DMA driver platform data

1  2 
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
drivers/gpu/drm/amd/include/amd_shared.h

index 023bfdb3e63f58dfd71c157cf663ac2b6220cd73,ebca22302ebb5e4704e20b7d6301d2fd415f5b48..c04f44a90392639e7ec3ae51da93a694ead70fee
  
  #include "acp_gfx_if.h"
  
 -#define ACP_TILE_ON_MASK                0x03
 -#define ACP_TILE_OFF_MASK               0x02
 -#define ACP_TILE_ON_RETAIN_REG_MASK     0x1f
 -#define ACP_TILE_OFF_RETAIN_REG_MASK    0x20
 -
 -#define ACP_TILE_P1_MASK                0x3e
 -#define ACP_TILE_P2_MASK                0x3d
 -#define ACP_TILE_DSP0_MASK              0x3b
 -#define ACP_TILE_DSP1_MASK              0x37
 -
 -#define ACP_TILE_DSP2_MASK              0x2f
 -
 -#define ACP_DMA_REGS_END              0x146c0
 -#define ACP_I2S_PLAY_REGS_START               0x14840
 -#define ACP_I2S_PLAY_REGS_END         0x148b4
 -#define ACP_I2S_CAP_REGS_START                0x148b8
 -#define ACP_I2S_CAP_REGS_END          0x1496c
 -
 -#define ACP_I2S_COMP1_CAP_REG_OFFSET  0xac
 -#define ACP_I2S_COMP2_CAP_REG_OFFSET  0xa8
 -#define ACP_I2S_COMP1_PLAY_REG_OFFSET 0x6c
 -#define ACP_I2S_COMP2_PLAY_REG_OFFSET 0x68
 -
 -#define mmACP_PGFSM_RETAIN_REG                0x51c9
 -#define mmACP_PGFSM_CONFIG_REG                0x51ca
 -#define mmACP_PGFSM_READ_REG_0                0x51cc
 -
 -#define mmACP_MEM_SHUT_DOWN_REQ_LO    0x51f8
 -#define mmACP_MEM_SHUT_DOWN_REQ_HI    0x51f9
 -#define mmACP_MEM_SHUT_DOWN_STS_LO    0x51fa
 -#define mmACP_MEM_SHUT_DOWN_STS_HI    0x51fb
 -
 -#define ACP_TIMEOUT_LOOP              0x000000FF
 -#define ACP_DEVS                      3
 -#define ACP_SRC_ID                    162
 +#define ACP_TILE_ON_MASK                      0x03
 +#define ACP_TILE_OFF_MASK                     0x02
 +#define ACP_TILE_ON_RETAIN_REG_MASK           0x1f
 +#define ACP_TILE_OFF_RETAIN_REG_MASK          0x20
 +
 +#define ACP_TILE_P1_MASK                      0x3e
 +#define ACP_TILE_P2_MASK                      0x3d
 +#define ACP_TILE_DSP0_MASK                    0x3b
 +#define ACP_TILE_DSP1_MASK                    0x37
 +
 +#define ACP_TILE_DSP2_MASK                    0x2f
 +
 +#define ACP_DMA_REGS_END                      0x146c0
 +#define ACP_I2S_PLAY_REGS_START                       0x14840
 +#define ACP_I2S_PLAY_REGS_END                 0x148b4
 +#define ACP_I2S_CAP_REGS_START                        0x148b8
 +#define ACP_I2S_CAP_REGS_END                  0x1496c
 +
 +#define ACP_I2S_COMP1_CAP_REG_OFFSET          0xac
 +#define ACP_I2S_COMP2_CAP_REG_OFFSET          0xa8
 +#define ACP_I2S_COMP1_PLAY_REG_OFFSET         0x6c
 +#define ACP_I2S_COMP2_PLAY_REG_OFFSET         0x68
 +
 +#define mmACP_PGFSM_RETAIN_REG                        0x51c9
 +#define mmACP_PGFSM_CONFIG_REG                        0x51ca
 +#define mmACP_PGFSM_READ_REG_0                        0x51cc
 +
 +#define mmACP_MEM_SHUT_DOWN_REQ_LO            0x51f8
 +#define mmACP_MEM_SHUT_DOWN_REQ_HI            0x51f9
 +#define mmACP_MEM_SHUT_DOWN_STS_LO            0x51fa
 +#define mmACP_MEM_SHUT_DOWN_STS_HI            0x51fb
 +
 +#define mmACP_CONTROL                         0x5131
 +#define mmACP_STATUS                          0x5133
 +#define mmACP_SOFT_RESET                      0x5134
 +#define ACP_CONTROL__ClkEn_MASK               0x1
 +#define ACP_SOFT_RESET__SoftResetAud_MASK     0x100
 +#define ACP_SOFT_RESET__SoftResetAudDone_MASK 0x1000000
 +#define ACP_CLOCK_EN_TIME_OUT_VALUE           0x000000FF
 +#define ACP_SOFT_RESET_DONE_TIME_OUT_VALUE    0x000000FF
 +
 +#define ACP_TIMEOUT_LOOP                      0x000000FF
 +#define ACP_DEVS                              3
 +#define ACP_SRC_ID                            162
  
  enum {
        ACP_TILE_P1 = 0,
@@@ -269,8 -260,6 +269,8 @@@ static int acp_hw_init(void *handle
  {
        int r, i;
        uint64_t acp_base;
 +      u32 val = 0;
 +      u32 count = 0;
        struct device *dev;
        struct i2s_platform_data *i2s_pdata;
  
        adev->acp.acp_cell[0].name = "acp_audio_dma";
        adev->acp.acp_cell[0].num_resources = 4;
        adev->acp.acp_cell[0].resources = &adev->acp.acp_res[0];
+       adev->acp.acp_cell[0].platform_data = &adev->asic_type;
+       adev->acp.acp_cell[0].pdata_size = sizeof(adev->asic_type);
  
        adev->acp.acp_cell[1].name = "designware-i2s";
        adev->acp.acp_cell[1].num_resources = 1;
                }
        }
  
 +      /* Assert Soft reset of ACP */
 +      val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET);
 +
 +      val |= ACP_SOFT_RESET__SoftResetAud_MASK;
 +      cgs_write_register(adev->acp.cgs_device, mmACP_SOFT_RESET, val);
 +
 +      count = ACP_SOFT_RESET_DONE_TIME_OUT_VALUE;
 +      while (true) {
 +              val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET);
 +              if (ACP_SOFT_RESET__SoftResetAudDone_MASK ==
 +                  (val & ACP_SOFT_RESET__SoftResetAudDone_MASK))
 +                      break;
 +              if (--count == 0) {
 +                      dev_err(&adev->pdev->dev, "Failed to reset ACP\n");
 +                      return -ETIMEDOUT;
 +              }
 +              udelay(100);
 +      }
 +      /* Enable clock to ACP and wait until the clock is enabled */
 +      val = cgs_read_register(adev->acp.cgs_device, mmACP_CONTROL);
 +      val = val | ACP_CONTROL__ClkEn_MASK;
 +      cgs_write_register(adev->acp.cgs_device, mmACP_CONTROL, val);
 +
 +      count = ACP_CLOCK_EN_TIME_OUT_VALUE;
 +
 +      while (true) {
 +              val = cgs_read_register(adev->acp.cgs_device, mmACP_STATUS);
 +              if (val & (u32) 0x1)
 +                      break;
 +              if (--count == 0) {
 +                      dev_err(&adev->pdev->dev, "Failed to reset ACP\n");
 +                      return -ETIMEDOUT;
 +              }
 +              udelay(100);
 +      }
 +      /* Deassert the SOFT RESET flags */
 +      val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET);
 +      val &= ~ACP_SOFT_RESET__SoftResetAud_MASK;
 +      cgs_write_register(adev->acp.cgs_device, mmACP_SOFT_RESET, val);
 +
        return 0;
  }
  
  static int acp_hw_fini(void *handle)
  {
        int i, ret;
 +      u32 val = 0;
 +      u32 count = 0;
        struct device *dev;
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  
        if (!adev->acp.acp_cell)
                return 0;
  
 +      /* Assert Soft reset of ACP */
 +      val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET);
 +
 +      val |= ACP_SOFT_RESET__SoftResetAud_MASK;
 +      cgs_write_register(adev->acp.cgs_device, mmACP_SOFT_RESET, val);
 +
 +      count = ACP_SOFT_RESET_DONE_TIME_OUT_VALUE;
 +      while (true) {
 +              val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET);
 +              if (ACP_SOFT_RESET__SoftResetAudDone_MASK ==
 +                  (val & ACP_SOFT_RESET__SoftResetAudDone_MASK))
 +                      break;
 +              if (--count == 0) {
 +                      dev_err(&adev->pdev->dev, "Failed to reset ACP\n");
 +                      return -ETIMEDOUT;
 +              }
 +              udelay(100);
 +      }
 +      /* Disable ACP clock */
 +      val = cgs_read_register(adev->acp.cgs_device, mmACP_CONTROL);
 +      val &= ~ACP_CONTROL__ClkEn_MASK;
 +      cgs_write_register(adev->acp.cgs_device, mmACP_CONTROL, val);
 +
 +      count = ACP_CLOCK_EN_TIME_OUT_VALUE;
 +
 +      while (true) {
 +              val = cgs_read_register(adev->acp.cgs_device, mmACP_STATUS);
 +              if (val & (u32) 0x1)
 +                      break;
 +              if (--count == 0) {
 +                      dev_err(&adev->pdev->dev, "Failed to reset ACP\n");
 +                      return -ETIMEDOUT;
 +              }
 +              udelay(100);
 +      }
 +
        if (adev->acp.acp_genpd) {
                for (i = 0; i < ACP_DEVS ; i++) {
                        dev = get_mfd_cell_dev(adev->acp.acp_cell[i].name, i);
index de6fc2731b982e9b71ca92fda3245c692d9664db,3a49fbd8baf88ecd4afb606dc3e8a9681cd59936..b72f8a43d86b43393198e0b737b6a8d654e89065
  #ifndef __AMD_SHARED_H__
  #define __AMD_SHARED_H__
  
- #define AMD_MAX_USEC_TIMEOUT          200000  /* 200 ms */
+ #include <drm/amd_asic_type.h>
  
- /*
-  * Supported ASIC types
-  */
- enum amd_asic_type {
-       CHIP_TAHITI = 0,
-       CHIP_PITCAIRN,
-       CHIP_VERDE,
-       CHIP_OLAND,
-       CHIP_HAINAN,
-       CHIP_BONAIRE,
-       CHIP_KAVERI,
-       CHIP_KABINI,
-       CHIP_HAWAII,
-       CHIP_MULLINS,
-       CHIP_TOPAZ,
-       CHIP_TONGA,
-       CHIP_FIJI,
-       CHIP_CARRIZO,
-       CHIP_STONEY,
-       CHIP_POLARIS10,
-       CHIP_POLARIS11,
-       CHIP_POLARIS12,
-       CHIP_VEGA10,
-       CHIP_RAVEN,
-       CHIP_LAST,
- };
 +struct seq_file;
 +
+ #define AMD_MAX_USEC_TIMEOUT          200000  /* 200 ms */
  
  /*
   * Chip flags
@@@ -146,12 -119,6 +121,12 @@@ enum amd_fan_ctrl_mode 
        AMD_FAN_CTRL_AUTO = 2,
  };
  
 +enum pp_clock_type {
 +      PP_SCLK,
 +      PP_MCLK,
 +      PP_PCIE,
 +};
 +
  /* CG flags */
  #define AMD_CG_SUPPORT_GFX_MGCG                       (1 << 0)
  #define AMD_CG_SUPPORT_GFX_MGLS                       (1 << 1)
@@@ -257,96 -224,4 +232,96 @@@ struct amd_ip_funcs 
        void (*get_clockgating_state)(void *handle, u32 *flags);
  };
  
 +
 +enum amd_pp_task;
 +enum amd_pp_clock_type;
 +struct pp_states_info;
 +struct amd_pp_simple_clock_info;
 +struct amd_pp_display_configuration;
 +struct amd_pp_clock_info;
 +struct pp_display_clock_request;
 +struct pp_wm_sets_with_clock_ranges_soc15;
 +struct pp_clock_levels_with_voltage;
 +struct pp_clock_levels_with_latency;
 +struct amd_pp_clocks;
 +
 +struct amd_pm_funcs {
 +/* export for dpm on ci and si */
 +      int (*pre_set_power_state)(void *handle);
 +      int (*set_power_state)(void *handle);
 +      void (*post_set_power_state)(void *handle);
 +      void (*display_configuration_changed)(void *handle);
 +      void (*print_power_state)(void *handle, void *ps);
 +      bool (*vblank_too_short)(void *handle);
 +      void (*enable_bapm)(void *handle, bool enable);
 +      int (*check_state_equal)(void *handle,
 +                              void  *cps,
 +                              void  *rps,
 +                              bool  *equal);
 +/* export for sysfs */
 +      int (*get_temperature)(void *handle);
 +      void (*set_fan_control_mode)(void *handle, u32 mode);
 +      u32 (*get_fan_control_mode)(void *handle);
 +      int (*set_fan_speed_percent)(void *handle, u32 speed);
 +      int (*get_fan_speed_percent)(void *handle, u32 *speed);
 +      int (*force_clock_level)(void *handle, enum pp_clock_type type, uint32_t mask);
 +      int (*print_clock_levels)(void *handle, enum pp_clock_type type, char *buf);
 +      int (*force_performance_level)(void *handle, enum amd_dpm_forced_level level);
 +      int (*get_sclk_od)(void *handle);
 +      int (*set_sclk_od)(void *handle, uint32_t value);
 +      int (*get_mclk_od)(void *handle);
 +      int (*set_mclk_od)(void *handle, uint32_t value);
 +      int (*read_sensor)(void *handle, int idx, void *value, int *size);
 +      enum amd_dpm_forced_level (*get_performance_level)(void *handle);
 +      enum amd_pm_state_type (*get_current_power_state)(void *handle);
 +      int (*get_fan_speed_rpm)(void *handle, uint32_t *rpm);
 +      int (*get_pp_num_states)(void *handle, struct pp_states_info *data);
 +      int (*get_pp_table)(void *handle, char **table);
 +      int (*set_pp_table)(void *handle, const char *buf, size_t size);
 +      void (*debugfs_print_current_performance_level)(void *handle, struct seq_file *m);
 +
 +      int (*reset_power_profile_state)(void *handle,
 +                      struct amd_pp_profile *request);
 +      int (*get_power_profile_state)(void *handle,
 +                      struct amd_pp_profile *query);
 +      int (*set_power_profile_state)(void *handle,
 +                      struct amd_pp_profile *request);
 +      int (*switch_power_profile)(void *handle,
 +                      enum amd_pp_profile_type type);
 +/* export to amdgpu */
 +      void (*powergate_uvd)(void *handle, bool gate);
 +      void (*powergate_vce)(void *handle, bool gate);
 +      struct amd_vce_state* (*get_vce_clock_state)(void *handle, u32 idx);
 +      int (*dispatch_tasks)(void *handle, enum amd_pp_task task_id,
 +                                 void *input, void *output);
 +      int (*load_firmware)(void *handle);
 +      int (*wait_for_fw_loading_complete)(void *handle);
 +      int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id);
 +/* export to DC */
 +      u32 (*get_sclk)(void *handle, bool low);
 +      u32 (*get_mclk)(void *handle, bool low);
 +      int (*display_configuration_change)(void *handle,
 +              const struct amd_pp_display_configuration *input);
 +      int (*get_display_power_level)(void *handle,
 +              struct amd_pp_simple_clock_info *output);
 +      int (*get_current_clocks)(void *handle,
 +              struct amd_pp_clock_info *clocks);
 +      int (*get_clock_by_type)(void *handle,
 +              enum amd_pp_clock_type type,
 +              struct amd_pp_clocks *clocks);
 +      int (*get_clock_by_type_with_latency)(void *handle,
 +              enum amd_pp_clock_type type,
 +              struct pp_clock_levels_with_latency *clocks);
 +      int (*get_clock_by_type_with_voltage)(void *handle,
 +              enum amd_pp_clock_type type,
 +              struct pp_clock_levels_with_voltage *clocks);
 +      int (*set_watermarks_for_clocks_ranges)(void *handle,
 +              struct pp_wm_sets_with_clock_ranges_soc15 *wm_with_clock_ranges);
 +      int (*display_clock_voltage_request)(void *handle,
 +              struct pp_display_clock_request *clock);
 +      int (*get_display_mode_validation_clocks)(void *handle,
 +              struct amd_pp_simple_clock_info *clocks);
 +};
 +
 +
  #endif /* __AMD_SHARED_H__ */