mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 23:35:26 +07:00
drm/amd/display: Implement generic MUX registers (v2)
[Why] Logic & structures for generic regs does not exist in DC currently. [How] Implement register masks/shifts and relevant functions for generic mux, similar to existing HPD and DDC objects. V2: fix includes for kalloc/free (Alex) Signed-off-by: Murton Liu <murton.liu@amd.com> Reviewed-by: Aric Cyr <Aric.Cyr@amd.com> Acked-by: Joshua Aberback <Joshua.Aberback@amd.com> Acked-by: Leo Li <sunpeng.li@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
4c6a961807
commit
d40605b6d0
@ -24,7 +24,7 @@
|
||||
# It provides the control and status of HW GPIO pins.
|
||||
|
||||
GPIO = gpio_base.o gpio_service.o hw_factory.o \
|
||||
hw_gpio.o hw_hpd.o hw_ddc.o hw_translate.o
|
||||
hw_gpio.o hw_hpd.o hw_ddc.o hw_generic.o hw_translate.o
|
||||
|
||||
AMD_DAL_GPIO = $(addprefix $(AMDDALPATH)/dc/gpio/,$(GPIO))
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "../hw_gpio.h"
|
||||
#include "../hw_ddc.h"
|
||||
#include "../hw_hpd.h"
|
||||
#include "../hw_generic.h"
|
||||
|
||||
#include "hw_factory_dcn20.h"
|
||||
|
||||
@ -138,6 +139,32 @@ static const struct ddc_sh_mask ddc_mask[] = {
|
||||
DDC_MASK_SH_LIST_DCN2(_MASK, 6)
|
||||
};
|
||||
|
||||
#include "../generic_regs.h"
|
||||
|
||||
/* set field name */
|
||||
#define SF_GENERIC(reg_name, field_name, post_fix)\
|
||||
.field_name = reg_name ## __ ## field_name ## post_fix
|
||||
|
||||
#define generic_regs(id) \
|
||||
{\
|
||||
GENERIC_REG_LIST(id)\
|
||||
}
|
||||
|
||||
static const struct generic_registers generic_regs[] = {
|
||||
generic_regs(A),
|
||||
generic_regs(B),
|
||||
};
|
||||
|
||||
static const struct generic_sh_mask generic_shift[] = {
|
||||
GENERIC_MASK_SH_LIST(__SHIFT, A),
|
||||
GENERIC_MASK_SH_LIST(__SHIFT, B),
|
||||
};
|
||||
|
||||
static const struct generic_sh_mask generic_mask[] = {
|
||||
GENERIC_MASK_SH_LIST(_MASK, A),
|
||||
GENERIC_MASK_SH_LIST(_MASK, B),
|
||||
};
|
||||
|
||||
static void define_ddc_registers(
|
||||
struct hw_gpio_pin *pin,
|
||||
uint32_t en)
|
||||
@ -173,17 +200,27 @@ static void define_hpd_registers(struct hw_gpio_pin *pin, uint32_t en)
|
||||
hpd->base.regs = &hpd_regs[en].gpio;
|
||||
}
|
||||
|
||||
static void define_generic_registers(struct hw_gpio_pin *pin, uint32_t en)
|
||||
{
|
||||
struct hw_generic *generic = HW_GENERIC_FROM_BASE(pin);
|
||||
|
||||
generic->regs = &generic_regs[en];
|
||||
generic->shifts = &generic_shift[en];
|
||||
generic->masks = &generic_mask[en];
|
||||
generic->base.regs = &generic_regs[en].gpio;
|
||||
}
|
||||
|
||||
/* fucntion table */
|
||||
static const struct hw_factory_funcs funcs = {
|
||||
.create_ddc_data = dal_hw_ddc_create,
|
||||
.create_ddc_clock = dal_hw_ddc_create,
|
||||
.create_generic = NULL,
|
||||
.create_generic = dal_hw_generic_create,
|
||||
.create_hpd = dal_hw_hpd_create,
|
||||
.create_sync = NULL,
|
||||
.create_gsl = NULL,
|
||||
.define_hpd_registers = define_hpd_registers,
|
||||
.define_ddc_registers = define_ddc_registers
|
||||
.define_ddc_registers = define_ddc_registers,
|
||||
.define_generic_registers = define_generic_registers,
|
||||
};
|
||||
/*
|
||||
* dal_hw_factory_dcn10_init
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "../hw_gpio.h"
|
||||
#include "../hw_ddc.h"
|
||||
#include "../hw_hpd.h"
|
||||
#include "../hw_generic.h"
|
||||
|
||||
/* function table */
|
||||
static const struct hw_factory_funcs funcs = {
|
||||
|
66
drivers/gpu/drm/amd/display/dc/gpio/generic_regs.h
Normal file
66
drivers/gpu/drm/amd/display/dc/gpio/generic_regs.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2012-16 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors: AMD
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DRIVERS_GPU_DRM_AMD_DC_DEV_DC_GPIO_GENERIC_REGS_H_
|
||||
#define DRIVERS_GPU_DRM_AMD_DC_DEV_DC_GPIO_GENERIC_REGS_H_
|
||||
|
||||
#include "gpio_regs.h"
|
||||
|
||||
#define GENERIC_GPIO_REG_LIST_ENTRY(type, cd, id) \
|
||||
.type ## _reg = REG(DC_GPIO_GENERIC_## type),\
|
||||
.type ## _mask = DC_GPIO_GENERIC_ ## type ## __DC_GPIO_GENERIC ## id ## _ ## type ## _MASK,\
|
||||
.type ## _shift = DC_GPIO_GENERIC_ ## type ## __DC_GPIO_GENERIC ## id ## _ ## type ## __SHIFT
|
||||
|
||||
#define GENERIC_GPIO_REG_LIST(id) \
|
||||
{\
|
||||
GENERIC_GPIO_REG_LIST_ENTRY(MASK, cd, id),\
|
||||
GENERIC_GPIO_REG_LIST_ENTRY(A, cd, id),\
|
||||
GENERIC_GPIO_REG_LIST_ENTRY(EN, cd, id),\
|
||||
GENERIC_GPIO_REG_LIST_ENTRY(Y, cd, id)\
|
||||
}
|
||||
|
||||
#define GENERIC_REG_LIST(id) \
|
||||
GENERIC_GPIO_REG_LIST(id), \
|
||||
.mux = REG(DC_GENERIC ## id),\
|
||||
|
||||
#define GENERIC_MASK_SH_LIST(mask_sh, cd) \
|
||||
{(DC_GENERIC ## cd ##__GENERIC ## cd ##_EN## mask_sh),\
|
||||
(DC_GENERIC ## cd ##__GENERIC ## cd ##_SEL## mask_sh)}
|
||||
|
||||
struct generic_registers {
|
||||
struct gpio_registers gpio;
|
||||
uint32_t mux;
|
||||
};
|
||||
|
||||
struct generic_sh_mask {
|
||||
/* enable */
|
||||
uint32_t GENERIC_EN;
|
||||
/* select */
|
||||
uint32_t GENERIC_SEL;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_GPIO_GENERIC_REGS_H_ */
|
@ -63,6 +63,9 @@ struct hw_factory {
|
||||
void (*define_ddc_registers)(
|
||||
struct hw_gpio_pin *pin,
|
||||
uint32_t en);
|
||||
void (*define_generic_registers)(
|
||||
struct hw_gpio_pin *pin,
|
||||
uint32_t en);
|
||||
} *funcs;
|
||||
};
|
||||
|
||||
|
134
drivers/gpu/drm/amd/display/dc/gpio/hw_generic.c
Normal file
134
drivers/gpu/drm/amd/display/dc/gpio/hw_generic.c
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright 2012-15 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors: AMD
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "dm_services.h"
|
||||
|
||||
#include "include/gpio_types.h"
|
||||
#include "hw_gpio.h"
|
||||
#include "hw_generic.h"
|
||||
|
||||
#include "reg_helper.h"
|
||||
#include "generic_regs.h"
|
||||
|
||||
#undef FN
|
||||
#define FN(reg_name, field_name) \
|
||||
generic->shifts->field_name, generic->masks->field_name
|
||||
|
||||
#define CTX \
|
||||
generic->base.base.ctx
|
||||
#define REG(reg)\
|
||||
(generic->regs->reg)
|
||||
|
||||
static void dal_hw_generic_construct(
|
||||
struct hw_generic *pin,
|
||||
enum gpio_id id,
|
||||
uint32_t en,
|
||||
struct dc_context *ctx)
|
||||
{
|
||||
dal_hw_gpio_construct(&pin->base, id, en, ctx);
|
||||
}
|
||||
|
||||
static void dal_hw_generic_destruct(
|
||||
struct hw_generic *pin)
|
||||
{
|
||||
dal_hw_gpio_destruct(&pin->base);
|
||||
}
|
||||
|
||||
static void destroy(
|
||||
struct hw_gpio_pin **ptr)
|
||||
{
|
||||
struct hw_generic *generic = HW_GENERIC_FROM_BASE(*ptr);
|
||||
|
||||
dal_hw_generic_destruct(generic);
|
||||
|
||||
kfree(generic);
|
||||
|
||||
*ptr = NULL;
|
||||
}
|
||||
|
||||
static enum gpio_result set_config(
|
||||
struct hw_gpio_pin *ptr,
|
||||
const struct gpio_config_data *config_data)
|
||||
{
|
||||
struct hw_generic *generic = HW_GENERIC_FROM_BASE(ptr);
|
||||
|
||||
if (!config_data)
|
||||
return GPIO_RESULT_INVALID_DATA;
|
||||
|
||||
REG_UPDATE_2(mux,
|
||||
GENERIC_EN, config_data->config.generic_mux.enable_output_from_mux,
|
||||
GENERIC_SEL, config_data->config.generic_mux.mux_select);
|
||||
|
||||
return GPIO_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct hw_gpio_pin_funcs funcs = {
|
||||
.destroy = destroy,
|
||||
.open = dal_hw_gpio_open,
|
||||
.get_value = dal_hw_gpio_get_value,
|
||||
.set_value = dal_hw_gpio_set_value,
|
||||
.set_config = set_config,
|
||||
.change_mode = dal_hw_gpio_change_mode,
|
||||
.close = dal_hw_gpio_close,
|
||||
};
|
||||
|
||||
static void construct(
|
||||
struct hw_generic *generic,
|
||||
enum gpio_id id,
|
||||
uint32_t en,
|
||||
struct dc_context *ctx)
|
||||
{
|
||||
dal_hw_generic_construct(generic, id, en, ctx);
|
||||
generic->base.base.funcs = &funcs;
|
||||
}
|
||||
|
||||
struct hw_gpio_pin *dal_hw_generic_create(
|
||||
struct dc_context *ctx,
|
||||
enum gpio_id id,
|
||||
uint32_t en)
|
||||
{
|
||||
struct hw_generic *generic;
|
||||
|
||||
if (id != GPIO_ID_GENERIC) {
|
||||
ASSERT_CRITICAL(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((en < GPIO_GENERIC_MIN) || (en > GPIO_GENERIC_MAX)) {
|
||||
ASSERT_CRITICAL(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
generic = kzalloc(sizeof(struct hw_generic), GFP_KERNEL);
|
||||
if (!generic) {
|
||||
ASSERT_CRITICAL(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
construct(generic, id, en, ctx);
|
||||
return &generic->base.base;
|
||||
}
|
46
drivers/gpu/drm/amd/display/dc/gpio/hw_generic.h
Normal file
46
drivers/gpu/drm/amd/display/dc/gpio/hw_generic.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2012-15 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors: AMD
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __DAL_HW_generic_H__
|
||||
#define __DAL_HW_generic_H__
|
||||
|
||||
#include "generic_regs.h"
|
||||
|
||||
struct hw_generic {
|
||||
struct hw_gpio base;
|
||||
const struct generic_registers *regs;
|
||||
const struct generic_sh_mask *shifts;
|
||||
const struct generic_sh_mask *masks;
|
||||
};
|
||||
|
||||
#define HW_GENERIC_FROM_BASE(hw_gpio) \
|
||||
container_of((HW_GPIO_FROM_BASE(hw_gpio)), struct hw_generic, base)
|
||||
|
||||
struct hw_gpio_pin *dal_hw_generic_create(
|
||||
struct dc_context *ctx,
|
||||
enum gpio_id id,
|
||||
uint32_t en);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user