/*
 * Copyright 2021,2022 Sony Corporation
 */

#include <common.h>
#include <debug_impl.h>
#include <autodet.h>

#define ERROR_CHECK(func)									\
	({											\
		int err = func;									\
		if (err == AUTODET_NO_RULES)							\
			UBOOT_ERROR("device rules error.\n");					\
												\
		if (err == AUTODET_NO_DATA)							\
			UBOOT_ERROR("device data error.\n");					\
	})

static int sony_pcd_overlay(void)
{
	ERROR_CHECK(select_sony_pcd_overlay("Multikey_Chassis"));
	ERROR_CHECK(select_sony_pcd_overlay("Display_Device"));
	ERROR_CHECK(select_sony_pcd_overlay("Multikey_MMAP"));
	ERROR_CHECK(select_sony_pcd_overlay("PQU_MMAP"));

	return 0;
}

static int sony_pcd_i2c_overlay(void)
{
	return 0;
}

static int sony_pcd_adc_overlay(void)
{
	return 0;
}

static int sony_adc_i2c_overlay(void)
{
	return 0;
}

static int sony_pcd_gpio_overlay(void)
{
	return 0;
}

static int sony_gpio_i2c_overlay(void)
{
	return 0;
}

static int sony_adc_overlay(void)
{
	return 0;
}

static int sony_gpio_overlay(void)
{
	return 0;
}

static int sony_i2c_overlay(void)
{
	return 0;
}

int select_sony_overlay_for_uboot(void)
{
	// PCD overlay
	sony_pcd_overlay();

	// PCD I2C overlay
	sony_pcd_i2c_overlay();

	// PCD ADC overlay
	sony_pcd_adc_overlay();

	// ADC I2C overlay
	sony_adc_i2c_overlay();

	// PCD GPIO overlay
	sony_pcd_gpio_overlay();

	// GPIO I2C overlay
	sony_gpio_i2c_overlay();

	// ADC overlay
	sony_adc_overlay();

	// GPIO overlay
	sony_gpio_overlay();

	// I2C overlay
	sony_i2c_overlay();

	return 0;
}
