2018-08-14 17:42:27 +05:30
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2018, The Linux Foundation. All rights reserved.
# include <linux/kernel.h>
# include <linux/init.h>
# include <linux/module.h>
# include <linux/platform_device.h>
# include <linux/err.h>
# include <linux/io.h>
# include <linux/of.h>
# include <linux/of_device.h>
# include <linux/clk.h>
# include <linux/clk-provider.h>
2022-09-14 16:47:43 +02:00
static const struct clk_parent_data aux_parents [ ] = {
{ . fw_name = " pll8_vote " , . name = " pll8_vote " } ,
{ . fw_name = " pxo " , . name = " pxo_board " } ,
2018-08-14 17:42:27 +05:30
} ;
2022-02-05 11:36:12 +01:00
static const u32 aux_parent_map [ ] = {
2018-08-14 17:42:27 +05:30
3 ,
0 ,
} ;
static const struct of_device_id kpss_xcc_match_table [ ] = {
{ . compatible = " qcom,kpss-acc-v1 " , . data = ( void * ) 1UL } ,
{ . compatible = " qcom,kpss-gcc " } ,
{ }
} ;
MODULE_DEVICE_TABLE ( of , kpss_xcc_match_table ) ;
static int kpss_xcc_driver_probe ( struct platform_device * pdev )
{
2022-11-08 22:17:34 +01:00
struct device * dev = & pdev - > dev ;
2018-08-14 17:42:27 +05:30
const struct of_device_id * id ;
void __iomem * base ;
2022-09-14 16:47:43 +02:00
struct clk_hw * hw ;
2018-08-14 17:42:27 +05:30
const char * name ;
2022-11-08 22:17:34 +01:00
id = of_match_device ( kpss_xcc_match_table , dev ) ;
2018-08-14 17:42:27 +05:30
if ( ! id )
return - ENODEV ;
2021-09-07 16:48:57 +08:00
base = devm_platform_ioremap_resource ( pdev , 0 ) ;
2018-08-14 17:42:27 +05:30
if ( IS_ERR ( base ) )
return PTR_ERR ( base ) ;
if ( id - > data ) {
2022-11-08 22:17:34 +01:00
if ( of_property_read_string_index ( dev - > of_node ,
2018-08-14 17:42:27 +05:30
" clock-output-names " ,
0 , & name ) )
return - ENODEV ;
base + = 0x14 ;
} else {
name = " acpu_l2_aux " ;
base + = 0x28 ;
}
2022-11-08 22:17:34 +01:00
hw = devm_clk_hw_register_mux_parent_data_table ( dev , name , aux_parents ,
2022-09-14 16:47:43 +02:00
ARRAY_SIZE ( aux_parents ) , 0 ,
base , 0 , 0x3 ,
0 , aux_parent_map , NULL ) ;
2022-11-08 22:17:34 +01:00
if ( IS_ERR ( hw ) )
return PTR_ERR ( hw ) ;
2018-08-14 17:42:27 +05:30
2022-11-08 22:17:34 +01:00
of_clk_add_hw_provider ( dev - > of_node , of_clk_hw_simple_get , hw ) ;
return 0 ;
2018-08-14 17:42:27 +05:30
}
static struct platform_driver kpss_xcc_driver = {
. probe = kpss_xcc_driver_probe ,
. driver = {
. name = " kpss-xcc " ,
. of_match_table = kpss_xcc_match_table ,
} ,
} ;
module_platform_driver ( kpss_xcc_driver ) ;
MODULE_DESCRIPTION ( " Krait Processor Sub System (KPSS) Clock Driver " ) ;
MODULE_LICENSE ( " GPL v2 " ) ;
MODULE_ALIAS ( " platform:kpss-xcc " ) ;