Commit d40605b6 authored by Murton Liu's avatar Murton Liu Committed by Alex Deucher
Browse files

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: default avatarMurton Liu <murton.liu@amd.com>
Reviewed-by: default avatarAric Cyr <Aric.Cyr@amd.com>
Acked-by: default avatarJoshua Aberback <Joshua.Aberback@amd.com>
Acked-by: default avatarLeo Li <sunpeng.li@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 4c6a9618
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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))

+39 −2
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
/*
 * 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_ */
+3 −0
Original line number Diff line number Diff line
@@ -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;
};

Loading