2020-08-09 23:51:01 +02:00
// SPDX-License-Identifier: GPL-2.0
# include <linux/device.h>
# include <linux/module.h>
# include <linux/spi/spi.h>
# include <linux/delay.h>
2021-06-14 20:11:35 +02:00
# include <drm/drm_mipi_dbi.h>
2020-08-09 23:51:01 +02:00
# include <drm/drm_print.h>
# include "panel-samsung-s6e63m0.h"
2021-06-14 20:11:35 +02:00
static const u8 s6e63m0_dbi_read_commands [ ] = {
MCS_READ_ID1 ,
MCS_READ_ID2 ,
MCS_READ_ID3 ,
0 , /* sentinel */
} ;
2020-08-09 23:51:01 +02:00
2021-06-14 20:11:35 +02:00
static int s6e63m0_spi_dcs_read ( struct device * dev , void * trsp ,
const u8 cmd , u8 * data )
2020-08-09 23:51:03 +02:00
{
2021-06-14 20:11:35 +02:00
struct mipi_dbi * dbi = trsp ;
2020-11-11 00:46:50 +01:00
int ret ;
2020-08-09 23:51:03 +02:00
2021-06-14 20:11:35 +02:00
ret = mipi_dbi_command_read ( dbi , cmd , data ) ;
if ( ret )
dev_err ( dev , " error on DBI read command %02x \n " , cmd ) ;
2020-11-11 00:46:50 +01:00
return ret ;
2020-08-09 23:51:03 +02:00
}
2021-06-14 20:11:35 +02:00
static int s6e63m0_spi_dcs_write ( struct device * dev , void * trsp ,
const u8 * data , size_t len )
2020-08-09 23:51:01 +02:00
{
2021-06-14 20:11:35 +02:00
struct mipi_dbi * dbi = trsp ;
int ret ;
2020-08-09 23:51:01 +02:00
2021-06-14 20:11:35 +02:00
ret = mipi_dbi_command_stackbuf ( dbi , data [ 0 ] , ( data + 1 ) , ( len - 1 ) ) ;
2020-08-09 23:51:01 +02:00
usleep_range ( 300 , 310 ) ;
return ret ;
}
static int s6e63m0_spi_probe ( struct spi_device * spi )
{
struct device * dev = & spi - > dev ;
2021-06-14 20:11:35 +02:00
struct mipi_dbi * dbi ;
2020-08-09 23:51:01 +02:00
int ret ;
2021-06-14 20:11:35 +02:00
dbi = devm_kzalloc ( dev , sizeof ( * dbi ) , GFP_KERNEL ) ;
if ( ! dbi )
return - ENOMEM ;
ret = mipi_dbi_spi_init ( spi , dbi , NULL ) ;
if ( ret )
return dev_err_probe ( dev , ret , " MIPI DBI init failed \n " ) ;
/* Register our custom MCS read commands */
dbi - > read_commands = s6e63m0_dbi_read_commands ;
return s6e63m0_probe ( dev , dbi , s6e63m0_spi_dcs_read ,
s6e63m0_spi_dcs_write , false ) ;
2020-08-09 23:51:01 +02:00
}
2022-01-23 18:52:01 +01:00
static void s6e63m0_spi_remove ( struct spi_device * spi )
2020-08-09 23:51:01 +02:00
{
2021-10-11 15:27:42 +02:00
s6e63m0_remove ( & spi - > dev ) ;
2020-08-09 23:51:01 +02:00
}
static const struct of_device_id s6e63m0_spi_of_match [ ] = {
{ . compatible = " samsung,s6e63m0 " } ,
{ /* sentinel */ }
} ;
MODULE_DEVICE_TABLE ( of , s6e63m0_spi_of_match ) ;
static struct spi_driver s6e63m0_spi_driver = {
. probe = s6e63m0_spi_probe ,
. remove = s6e63m0_spi_remove ,
. driver = {
. name = " panel-samsung-s6e63m0 " ,
. of_match_table = s6e63m0_spi_of_match ,
} ,
} ;
module_spi_driver ( s6e63m0_spi_driver ) ;
MODULE_AUTHOR ( " Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com> " ) ;
MODULE_DESCRIPTION ( " s6e63m0 LCD SPI Driver " ) ;
MODULE_LICENSE ( " GPL v2 " ) ;