|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 g! H3 B5 ?1 i7 S#include <linux/init.h>. u- @$ ]9 l, n9 P9 P& Q1 V8 N* ^- y, q. N
#include <linux/module.h>3 v6 J9 k o4 T v2 }3 s
#include <linux/kernel.h>' n, S) o( h$ F
#include <linux/types.h>+ Z0 T5 K( ?# M
#include <linux/gpio.h>
+ k0 E% W" Q- R# D( K8 L#include <linux/leds.h>
( a) r/ k/ f3 d% p, w3 k7 D% q#include <linux/platform_device.h>$ n0 f- e% ]0 [$ j) ?
/ X! j, I0 Q ^#include <asm/mach-types.h>, w; f/ X/ C4 z% e
#include <asm/mach/arch.h>
( F8 ?( u5 r7 J6 k, @7 n* o- I$ I* A#include <mach/da8xx.h>
/ ~' \/ Y4 H" I( p6 l0 R1 w" \#include <mach/mux.h>
* H5 ]9 l2 U' A1 a7 M" ^0 h4 @+ u/ c
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ [. B ~3 [/ ^) S0 s8 z. ^; Q6 u7 Q4 ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! s8 Y$ K3 _! D9 x4 h7 L5 o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ Z& J6 p# E: t/ y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 ]! C% v+ @7 m% h
3 g/ v; h+ Q" p- t/* assign the tl som board LED-GPIOs*/- W t8 a$ F- v+ g) T
static const short da850_evm_tl_user_led_pins[] = {
N: L/ Q* t( g; N# G0 Q5 z' B* l /* These pins are definition at <mach/mux.h> file */
# S, ~+ l2 w9 ]0 q% O9 j* I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 H/ z5 G/ T- \+ H# b# d -1- j6 D3 N/ g: q- [; j9 P/ B
};. B2 V: R* ~6 D( l
. c. ]2 L- X1 A6 w. `- X
static struct gpio_led da850_evm_tl_leds[] = {
5 W8 m& d. F5 h& e {# |" ~9 s8 |5 k. u5 N% L
.active_low = 0,1 s% D# _3 Y) z: h! ~7 j4 S m
.gpio = DA850_USER_LED0," n, C+ j7 G$ c; u8 w- V
.name = "user_led0",
+ s3 L. }* {9 `1 f! T .default_trigger = "default-on",8 z, U1 m. a/ F& H# P" L& R
},6 \2 o4 f7 Y8 L0 X5 i. K
{
0 e3 q% C0 ]2 [, u$ J4 N .active_low = 0,
+ y, `- o: B% t' o9 k1 ^ .gpio = DA850_USER_LED1,) {+ J( p5 k0 F6 |- y5 p9 S
.name = "user_led1",, ^6 {; Z {* u! K6 M. K. a' b
.default_trigger = "default-on",
n9 A: b% R" O0 v },; P0 Y$ ]( y& a- w, v0 p
{
3 F+ V w6 ~# j. g" r5 G .active_low = 0,
. A- U5 D8 s9 n% _9 Q .gpio = DA850_USER_LED2,
2 H( N, d8 E$ M- b5 v6 v+ E) K+ { .name = "user_led2",* f) c5 x1 L" g8 L; m
.default_trigger = "default-on",% w2 g' C3 u! O1 l* ]5 c3 t" z
},6 k5 U; d: B5 B& b5 u j/ |2 w
{
8 q* Z+ q- _2 t0 n1 v .active_low = 0,9 c& c0 {( l- [3 W- H/ | ^& H0 E" l
.gpio = DA850_USER_LED3,
0 G1 w# l. r% o" O2 ?$ X7 u7 ` .name = "user_led3",1 m8 U2 j7 P6 h: ?+ N
.default_trigger = "default-on",
! E% W3 Y+ J' A6 m },( c; I" [% X4 s' @& g* ~5 d
};! U1 q. }. d5 |0 K0 F4 o
. @8 `% h- a. z* S) n7 Q/ G {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 E+ ^* l! s: @+ o: T: T .leds = da850_evm_tl_leds,
. l5 d) m$ e. s; i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 }# q5 A( x, x) i5 Y/ K7 `! O
};* j- w: F. Y4 M' |0 N& K
9 D a0 |# S$ J% w7 x$ _3 C
static void led_dev_release(struct device *dev)
( j3 k& @/ Q& m& A" o6 s{
& M- |) n2 o# e m. H3 w0 Z" J};
`2 H2 x+ J! m* h! Z0 C4 a( }# X( z+ O8 ~
static struct platform_device da850_evm_tl_leds_device = {8 I5 `9 X+ J4 C0 ~
.name = "leds-gpio",& y; }: \' v9 H# ^- ]5 A
.id = 1,
" _% t) ~$ L/ `3 r; T5 F8 h& u0 g .dev = {
! P. {- o9 P+ i7 B4 [4 Y2 t .platform_data = &da850_evm_tl_leds_pdata,
9 Q+ P3 h# {2 O+ A .release = led_dev_release,# ]0 u' I; G) e; H/ |6 w; t' |
}$ C5 \: O& F+ G, \' {
};" Z- F) O# _ E
* ^/ r1 b' |! ^1 l; ^: V* \: E( `static int __init led_platform_init(void)6 R7 \+ e& L+ J
{
: p* y6 s3 T: {) ^* E$ A int ret;
; f) s2 T' o- k: m4 ~% z#if 0
' o; m0 ]" b6 e0 z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 K% u# y6 V q7 u2 U
if (ret), h8 P( F3 G1 m% |6 B9 [$ l( ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 M5 |3 Z; s6 G7 j. n" d "%d\n", ret);, S. W: \/ y8 \: A$ R! b- {
#endif( Z2 ]# Q& q& a0 {
ret = platform_device_register(&da850_evm_tl_leds_device);
. g& p& i9 X% P& c4 J: t+ j if (ret)7 H4 y1 C. y" O' {# J1 w6 B
pr_warning("Could not register som GPIO expander LEDS");$ S+ L+ t. H1 i& {: n/ E4 x
else% Q( }& d3 I/ s$ f
printk(KERN_INFO "LED register sucessful!\n");
! S/ T1 q) S1 m9 }- a
; |. W* y% {8 O5 v m; T% G return ret;
4 t. J; s0 ^" K6 }}
# T0 }. I7 |* h4 [0 a+ q0 _' t( ?8 x" o; `
static void __exit led_platform_exit(void), R, R" B2 k7 U2 n% f1 \7 A
{* s3 k1 @" A2 g7 E* n3 M
platform_device_unregister(&da850_evm_tl_leds_device);# z( a! q7 T4 d$ Z0 N, d
& W6 L( B- Q- O" `
printk(KERN_INFO "LED unregister!\n");
2 g' V# c' R0 u& T+ }& g& v}+ i/ T8 L$ ^) j. L; n
3 M; {/ T$ Y$ f; j' c ], i
module_init(led_platform_init);+ ]+ J6 ]8 [; z, ~& W, w
module_exit(led_platform_exit);5 j: ~' C* F e; v+ L
8 }4 o8 S9 S" U- I
MODULE_DESCRIPTION("Led platform driver");, C2 M. m- }! l! \
MODULE_AUTHOR("Tronlong");
7 V# a) |+ ]! Z2 p0 h$ H' ^MODULE_LICENSE("GPL");
8 z# p/ e2 { e2 q% @$ @( K, `. \( S7 {. I) Y# i+ l( @
|
|