watchdog: dw: Make internal primitives Kconfig based

Base address, IRQ, interrupt priority as well as the instance name: all
are now Kconfig based. Thus Applying the change to quark_se and
quark_d2000 platforms. Sample code is updated as well.

Change-Id: Idcc89e6e9f4acc337fafc7d42f8de3061a5ece04
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
diff --git a/arch/x86/platforms/quark_d2000/Kconfig b/arch/x86/platforms/quark_d2000/Kconfig
index 903dd73..56382a7 100644
--- a/arch/x86/platforms/quark_d2000/Kconfig
+++ b/arch/x86/platforms/quark_d2000/Kconfig
@@ -140,4 +140,15 @@
 
 endif
 
+if WATCHDOG
+
+config WDT_DW
+	def_bool y
+config WDT_DW_BASE_ADDR
+	default 0xB0000000
+config WDT_DW_IRQ
+	default 16
+
+endif
+
 endif
diff --git a/arch/x86/platforms/quark_d2000/board.h b/arch/x86/platforms/quark_d2000/board.h
index 2579b7c..7039b36 100644
--- a/arch/x86/platforms/quark_d2000/board.h
+++ b/arch/x86/platforms/quark_d2000/board.h
@@ -127,8 +127,6 @@
 #define UART_IOAPIC_FLAGS       (IOAPIC_LEVEL)
 
 /* Watchdog */
-#define WDT_BASE_ADDR			0xB0000000
-#define INT_WDT_IRQ			0x10
 #define INT_WATCHDOG_MASK		0x47C
 #define SCSS_PERIPH_CFG0		0x4
 #define SCSS_PERIPH_CFG0_WDT_ENABLE	(1 << 1)
diff --git a/arch/x86/platforms/quark_se/Kconfig b/arch/x86/platforms/quark_se/Kconfig
index 9b3e585..6856d15 100644
--- a/arch/x86/platforms/quark_se/Kconfig
+++ b/arch/x86/platforms/quark_se/Kconfig
@@ -167,6 +167,15 @@
 	default 3
 endif
 
+if WATCHDOG
+config WDT_DW
+	def_bool y
+config WDT_DW_BASE_ADDR
+	default 0xB0000000
+config WDT_DW_IRQ
+	default 12
+endif
+
 config KERNEL_INIT_PRIORITY_DEFAULT
 	default 40
 
diff --git a/arch/x86/platforms/quark_se/board.h b/arch/x86/platforms/quark_se/board.h
index 84b031a..2ff3471 100644
--- a/arch/x86/platforms/quark_se/board.h
+++ b/arch/x86/platforms/quark_se/board.h
@@ -220,9 +220,6 @@
 #define CCU_PWM_PCLK_EN_SW     		(1 << 12)
 
 /* Watchdog */
-#define WDT_BASE_ADDR               	0xB0000000
-#define INT_WDT_IRQ               	0xc
-#define INT_WDT_IRQ_PRI              	2
 #define INT_WATCHDOG_MASK		0x47C
 #define SCSS_PERIPH_CFG0_WDT_ENABLE	(1 << 1)
 #define CCU_WDT_PCLK_EN_SW     		(1 << 10)
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index a671215..aab0da6 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1,3 +1,24 @@
+# Kconfig - Watchdog configuration options
+#
+#
+# Copyright (c) 2015 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Watchdog options
+#
 menuconfig WATCHDOG
 	bool
 	prompt "Watchdog Support"
@@ -12,4 +33,31 @@
 	help
 	Enable watchdog timer.
 
+config WDT_DW_DRV_NAME
+	string "Driver instance name"
+	default "WDT_DW"
+	depends on WDT_DW
+	help
+	Designware WDT driver instance name
+
+config WDT_DW_BASE_ADDR
+	hex "Base address"
+	default 0x00000000
+	depends on WDT_DW
+	help
+	Base address to access WDT DesignWare controller registers
+
+config WDT_DW_IRQ
+	int "Interrupt number"
+	default 0
+	depends on WDT_DW
+	help
+	DesignWare WDT interrupt number
+
+config WDT_DW_IRQ_PRI
+	int "Interrupt priority"
+	default 2
+	depends on WDT_DW
+	help
+	DesignWare WDT interrupt priority
 endif
diff --git a/drivers/watchdog/wdt_dw.c b/drivers/watchdog/wdt_dw.c
index 721fea4..0ce8325 100644
--- a/drivers/watchdog/wdt_dw.c
+++ b/drivers/watchdog/wdt_dw.c
@@ -107,14 +107,15 @@
 };
 
 /* IRQ_CONFIG needs the flags variable declared by IRQ_CONNECT_STATIC */
-IRQ_CONNECT_STATIC(wdt_dw, INT_WDT_IRQ, INT_WDT_IRQ_PRI, wdt_dw_isr, 0, 0);
+IRQ_CONNECT_STATIC(wdt_dw, CONFIG_WDT_DW_IRQ,
+		   CONFIG_WDT_DW_IRQ_PRI, wdt_dw_isr, 0, 0);
 
 int wdt_dw_init(struct device *dev)
 {
 	dev->driver_api = &wdt_dw_funcs;
 
-	IRQ_CONFIG(wdt_dw, INT_WDT_IRQ);
-	irq_enable(INT_WDT_IRQ);
+	IRQ_CONFIG(wdt_dw, CONFIG_WDT_DW_IRQ);
+	irq_enable(CONFIG_WDT_DW_IRQ);
 
 	return 0;
 }
@@ -122,10 +123,11 @@
 struct wdt_dw_runtime wdt_runtime;
 
 struct wdt_dw_dev_config wdt_dev = {
-	.base_address = WDT_BASE_ADDR,
+	.base_address = CONFIG_WDT_DW_BASE_ADDR,
 };
 
-DECLARE_DEVICE_INIT_CONFIG(wdt, WDT_DRV_NAME, &wdt_dw_init, &wdt_dev);
+DECLARE_DEVICE_INIT_CONFIG(wdt, CONFIG_WDT_DW_DRV_NAME,
+			   &wdt_dw_init, &wdt_dev);
 
 SYS_DEFINE_DEVICE(wdt, &wdt_runtime, SECONDARY,
 		  CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
diff --git a/drivers/watchdog/wdt_dw.h b/drivers/watchdog/wdt_dw.h
index f0db893..47fd370 100644
--- a/drivers/watchdog/wdt_dw.h
+++ b/drivers/watchdog/wdt_dw.h
@@ -45,8 +45,6 @@
 #define WDT_CR_INT_ENABLE	(1 << 1)
 
 
-#define WDT_DRV_NAME "wdt_dw"
-
 struct wdt_dw_runtime {
 	void (*cb_fn)(struct device *dev);
 };
diff --git a/samples/nanokernel/apps/watchdog/src/main.c b/samples/nanokernel/apps/watchdog/src/main.c
index 7a956a4..869d296 100644
--- a/samples/nanokernel/apps/watchdog/src/main.c
+++ b/samples/nanokernel/apps/watchdog/src/main.c
@@ -24,7 +24,7 @@
 
 uint32_t wdt_fired;
 
-#define WDT_DRIVER "wdt_dw"
+#define WDT_DRIVER CONFIG_WDT_DW_DRV_NAME
 
 /* WDT Requires a callback, there is no interrupt enable / disable. */
 void wdt_example_cb(struct device *dev)