LCOV - code coverage report
Current view: top level - drivers/gpu/drm/amd/display/dc/gpio - hw_hpd.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 34 0.0 %
Date: 2022-12-09 01:23:36 Functions: 0 5 0.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright 2012-15 Advanced Micro Devices, Inc.
       3             :  *
       4             :  * Permission is hereby granted, free of charge, to any person obtaining a
       5             :  * copy of this software and associated documentation files (the "Software"),
       6             :  * to deal in the Software without restriction, including without limitation
       7             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
       8             :  * and/or sell copies of the Software, and to permit persons to whom the
       9             :  * Software is furnished to do so, subject to the following conditions:
      10             :  *
      11             :  * The above copyright notice and this permission notice shall be included in
      12             :  * all copies or substantial portions of the Software.
      13             :  *
      14             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      15             :  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      16             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
      17             :  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
      18             :  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
      19             :  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
      20             :  * OTHER DEALINGS IN THE SOFTWARE.
      21             :  *
      22             :  * Authors: AMD
      23             :  *
      24             :  */
      25             : 
      26             : #include "dm_services.h"
      27             : 
      28             : #include "include/gpio_interface.h"
      29             : #include "include/gpio_types.h"
      30             : #include "hw_gpio.h"
      31             : #include "hw_hpd.h"
      32             : 
      33             : #include "reg_helper.h"
      34             : #include "hpd_regs.h"
      35             : 
      36             : #undef FN
      37             : #define FN(reg_name, field_name) \
      38             :         hpd->shifts->field_name, hpd->masks->field_name
      39             : 
      40             : #define CTX \
      41             :         hpd->base.base.ctx
      42             : #define REG(reg)\
      43             :         (hpd->regs->reg)
      44             : 
      45             : struct gpio;
      46             : 
      47             : static void dal_hw_hpd_destruct(
      48             :         struct hw_hpd *pin)
      49             : {
      50           0 :         dal_hw_gpio_destruct(&pin->base);
      51             : }
      52             : 
      53           0 : static void dal_hw_hpd_destroy(
      54             :         struct hw_gpio_pin **ptr)
      55             : {
      56           0 :         struct hw_hpd *hpd = HW_HPD_FROM_BASE(*ptr);
      57             : 
      58           0 :         dal_hw_hpd_destruct(hpd);
      59             : 
      60           0 :         kfree(hpd);
      61             : 
      62           0 :         *ptr = NULL;
      63           0 : }
      64             : 
      65           0 : static enum gpio_result get_value(
      66             :         const struct hw_gpio_pin *ptr,
      67             :         uint32_t *value)
      68             : {
      69           0 :         struct hw_hpd *hpd = HW_HPD_FROM_BASE(ptr);
      70           0 :         uint32_t hpd_delayed = 0;
      71             : 
      72             :         /* in Interrupt mode we ask for SENSE bit */
      73             : 
      74           0 :         if (ptr->mode == GPIO_MODE_INTERRUPT) {
      75             : 
      76           0 :                 REG_GET(int_status,
      77             :                         DC_HPD_SENSE_DELAYED, &hpd_delayed);
      78             : 
      79           0 :                 *value = hpd_delayed;
      80           0 :                 return GPIO_RESULT_OK;
      81             :         }
      82             : 
      83             :         /* in any other modes, operate as normal GPIO */
      84             : 
      85           0 :         return dal_hw_gpio_get_value(ptr, value);
      86             : }
      87             : 
      88           0 : static enum gpio_result set_config(
      89             :         struct hw_gpio_pin *ptr,
      90             :         const struct gpio_config_data *config_data)
      91             : {
      92           0 :         struct hw_hpd *hpd = HW_HPD_FROM_BASE(ptr);
      93             : 
      94           0 :         if (!config_data)
      95             :                 return GPIO_RESULT_INVALID_DATA;
      96             : 
      97           0 :         REG_UPDATE_2(toggle_filt_cntl,
      98             :                 DC_HPD_CONNECT_INT_DELAY, config_data->config.hpd.delay_on_connect / 10,
      99             :                 DC_HPD_DISCONNECT_INT_DELAY, config_data->config.hpd.delay_on_disconnect / 10);
     100             : 
     101           0 :         return GPIO_RESULT_OK;
     102             : }
     103             : 
     104             : static const struct hw_gpio_pin_funcs funcs = {
     105             :         .destroy = dal_hw_hpd_destroy,
     106             :         .open = dal_hw_gpio_open,
     107             :         .get_value = get_value,
     108             :         .set_value = dal_hw_gpio_set_value,
     109             :         .set_config = set_config,
     110             :         .change_mode = dal_hw_gpio_change_mode,
     111             :         .close = dal_hw_gpio_close,
     112             : };
     113             : 
     114             : static void dal_hw_hpd_construct(
     115             :         struct hw_hpd *pin,
     116             :         enum gpio_id id,
     117             :         uint32_t en,
     118             :         struct dc_context *ctx)
     119             : {
     120           0 :         dal_hw_gpio_construct(&pin->base, id, en, ctx);
     121           0 :         pin->base.base.funcs = &funcs;
     122             : }
     123             : 
     124           0 : void dal_hw_hpd_init(
     125             :         struct hw_hpd **hw_hpd,
     126             :         struct dc_context *ctx,
     127             :         enum gpio_id id,
     128             :         uint32_t en)
     129             : {
     130           0 :         if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) {
     131           0 :                 ASSERT_CRITICAL(false);
     132           0 :                 *hw_hpd = NULL;
     133             :         }
     134             : 
     135           0 :         *hw_hpd = kzalloc(sizeof(struct hw_hpd), GFP_KERNEL);
     136           0 :         if (!*hw_hpd) {
     137           0 :                 ASSERT_CRITICAL(false);
     138           0 :                 return;
     139             :         }
     140             : 
     141           0 :         dal_hw_hpd_construct(*hw_hpd, id, en, ctx);
     142             : }
     143             : 
     144           0 : struct hw_gpio_pin *dal_hw_hpd_get_pin(struct gpio *gpio)
     145             : {
     146           0 :         struct hw_hpd *hw_hpd = dal_gpio_get_hpd(gpio);
     147             : 
     148           0 :         return &hw_hpd->base.base;
     149             : }

Generated by: LCOV version 1.14