cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

panel-samsung-s6e63m0-spi.c (2024B)


      1// SPDX-License-Identifier: GPL-2.0
      2
      3#include <linux/device.h>
      4#include <linux/module.h>
      5#include <linux/spi/spi.h>
      6#include <linux/delay.h>
      7
      8#include <drm/drm_mipi_dbi.h>
      9#include <drm/drm_print.h>
     10
     11#include "panel-samsung-s6e63m0.h"
     12
     13static const u8 s6e63m0_dbi_read_commands[] = {
     14	MCS_READ_ID1,
     15	MCS_READ_ID2,
     16	MCS_READ_ID3,
     17	0, /* sentinel */
     18};
     19
     20static int s6e63m0_spi_dcs_read(struct device *dev, void *trsp,
     21				const u8 cmd, u8 *data)
     22{
     23	struct mipi_dbi *dbi = trsp;
     24	int ret;
     25
     26	ret = mipi_dbi_command_read(dbi, cmd, data);
     27	if (ret)
     28		dev_err(dev, "error on DBI read command %02x\n", cmd);
     29
     30	return ret;
     31}
     32
     33static int s6e63m0_spi_dcs_write(struct device *dev, void *trsp,
     34				 const u8 *data, size_t len)
     35{
     36	struct mipi_dbi *dbi = trsp;
     37	int ret;
     38
     39	ret = mipi_dbi_command_stackbuf(dbi, data[0], (data + 1), (len - 1));
     40	usleep_range(300, 310);
     41
     42	return ret;
     43}
     44
     45static int s6e63m0_spi_probe(struct spi_device *spi)
     46{
     47	struct device *dev = &spi->dev;
     48	struct mipi_dbi *dbi;
     49	int ret;
     50
     51	dbi = devm_kzalloc(dev, sizeof(*dbi), GFP_KERNEL);
     52	if (!dbi)
     53		return -ENOMEM;
     54
     55	ret = mipi_dbi_spi_init(spi, dbi, NULL);
     56	if (ret)
     57		return dev_err_probe(dev, ret, "MIPI DBI init failed\n");
     58	/* Register our custom MCS read commands */
     59	dbi->read_commands = s6e63m0_dbi_read_commands;
     60
     61	return s6e63m0_probe(dev, dbi, s6e63m0_spi_dcs_read,
     62			     s6e63m0_spi_dcs_write, false);
     63}
     64
     65static void s6e63m0_spi_remove(struct spi_device *spi)
     66{
     67	s6e63m0_remove(&spi->dev);
     68}
     69
     70static const struct of_device_id s6e63m0_spi_of_match[] = {
     71	{ .compatible = "samsung,s6e63m0" },
     72	{ /* sentinel */ }
     73};
     74MODULE_DEVICE_TABLE(of, s6e63m0_spi_of_match);
     75
     76static struct spi_driver s6e63m0_spi_driver = {
     77	.probe			= s6e63m0_spi_probe,
     78	.remove			= s6e63m0_spi_remove,
     79	.driver			= {
     80		.name		= "panel-samsung-s6e63m0",
     81		.of_match_table = s6e63m0_spi_of_match,
     82	},
     83};
     84module_spi_driver(s6e63m0_spi_driver);
     85
     86MODULE_AUTHOR("Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>");
     87MODULE_DESCRIPTION("s6e63m0 LCD SPI Driver");
     88MODULE_LICENSE("GPL v2");